This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

disable logging

I want to disable logging (which is working OK). In my app.config.h I have set the following:

#undef NRF_LOG_ENABLED
#define NRF_LOG_BACKEND_SERIAL_USES_UART 0
#define NRF_LOG_BACKEND_SERIAL_USES_RTT 1
#define NRF_LOG_DEFAULT_LEVEL 4

Now I get this during linking:

...../../../main.c:130: undefined reference to `nrf_log_frontend_std_0'
...../../../main.c:134: undefined reference to `nrf_log_frontend_std_1'

What have I forgotten please?

Parents
  • EDIT: I see that the app_config.h is included in the top of the sdk_config file if USE_APP_CONFIG is defined, so it is safe to use this. The problem is if NRF_LOG_ENABLED is defined as 0 and NRF_LOG_DEFAULT_LEVEL is defined as something higher than 0, then you may have linker errors if you try to use NRF_LOG functions. This is a bit confusing (even I did not know how it works at first), I will see if we can improve this.


    previous answer for reference:

    You can set the level to 0, which is OFF, this will disable the logging. You can define NRF_LOG_ENABLED=0, but if you do this in another config file than sdk_config.h, then you need to make sure that this config file is always included when the sdk_config.h file is included (and also probably best if included before the sdk_config.h file). If not, you will have different defines for different files and the linker may fail or worse, the code behaves strange. For this reason I would only use one config file (sdk_config.h).

Reply
  • EDIT: I see that the app_config.h is included in the top of the sdk_config file if USE_APP_CONFIG is defined, so it is safe to use this. The problem is if NRF_LOG_ENABLED is defined as 0 and NRF_LOG_DEFAULT_LEVEL is defined as something higher than 0, then you may have linker errors if you try to use NRF_LOG functions. This is a bit confusing (even I did not know how it works at first), I will see if we can improve this.


    previous answer for reference:

    You can set the level to 0, which is OFF, this will disable the logging. You can define NRF_LOG_ENABLED=0, but if you do this in another config file than sdk_config.h, then you need to make sure that this config file is always included when the sdk_config.h file is included (and also probably best if included before the sdk_config.h file). If not, you will have different defines for different files and the linker may fail or worse, the code behaves strange. For this reason I would only use one config file (sdk_config.h).

Children
Related