<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>disable logging</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/18993/disable-logging</link><description>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</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 05 Mar 2018 16:13:02 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/18993/disable-logging" /><item><title>RE: disable logging</title><link>https://devzone.nordicsemi.com/thread/122889?ContentTypeID=1</link><pubDate>Mon, 05 Mar 2018 16:13:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ea00d9ce-9979-4f4f-b192-c48ba7afa29b</guid><dc:creator>atharva</dc:creator><description>&lt;p&gt;Thanks for that! Spent way too long on that!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: disable logging</title><link>https://devzone.nordicsemi.com/thread/73423?ContentTypeID=1</link><pubDate>Thu, 19 Jan 2017 17:00:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:623f822d-8c6a-4471-bc1b-9f6d551e4dbe</guid><dc:creator>Michael Lamming</dc:creator><description>&lt;p&gt;Thanks for the feedback.  Relieved to hear it is actually a bit confusing, and not my stupidity.&lt;br /&gt;
So to clarify for other readers:  (verified by my own experiments)&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;To disable all logging:&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#define NRF_LOG_DEFAULT_LEVEL 0
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Any definition, or undefinition of NRF_LOG_ENABLED is irrelevant.&lt;/p&gt;
&lt;p&gt;Indeed if NRF_LOG_ENABLED=0 or is undefined, and NRF_LOG_DEFAULT_LEVEL &amp;gt;0 then linker errors will occur.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: disable logging</title><link>https://devzone.nordicsemi.com/thread/73421?ContentTypeID=1</link><pubDate>Thu, 19 Jan 2017 11:31:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3104dcae-1423-4c3f-ac3e-18c41de5088f</guid><dc:creator>Ole Bauck</dc:creator><description>&lt;p&gt;Answer updated, sorry for the confusion, you had it right :)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: disable logging</title><link>https://devzone.nordicsemi.com/thread/73422?ContentTypeID=1</link><pubDate>Thu, 19 Jan 2017 00:41:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4e25ec1f-8b2d-42ec-bc44-2f8f9d2e1ee5</guid><dc:creator>Michael Lamming</dc:creator><description>&lt;p&gt;The first line of my sdk_config.h, is #include app_config.h.  The app_config is useful because I have two different apps generated from the same code, and several hardware configs.  But I expect you have your finger on the issue.  Thanks very much for persevering with me.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: disable logging</title><link>https://devzone.nordicsemi.com/thread/73420?ContentTypeID=1</link><pubDate>Wed, 18 Jan 2017 12:46:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0ecc772d-c2aa-4912-856c-1c213e0f580e</guid><dc:creator>Ole Bauck</dc:creator><description>&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt; 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.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;previous answer for reference:&lt;/p&gt;
&lt;p&gt;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).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: disable logging</title><link>https://devzone.nordicsemi.com/thread/73418?ContentTypeID=1</link><pubDate>Tue, 17 Jan 2017 19:28:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6d9ba066-675d-4a06-8223-84c55565cf1f</guid><dc:creator>Michael Lamming</dc:creator><description>&lt;p&gt;Hi Ole,&lt;/p&gt;
&lt;p&gt;Kind of solved.&lt;/p&gt;
&lt;p&gt;I thought all logging would be disabled by defining NRF_LOG_ENABLED=0.  I see that this does not remove the print calls.  It only seems to remove the calls to the &amp;quot;getchar&amp;quot; functionality, as follows:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#if NRF_MODULE_ENABLED(NRF_LOG)
#define NRF_LOG_INTERNAL_GETCHAR()  nrf_log_getchar()
#else
#define NRF_LOG_INTERNAL_GETCHAR()  (void)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The print code appears not to be guarded by a similar conditional compile.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Solution&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#define NRF_LOG_DEFAULT_LEVEL 0
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Is this the correct method for disabling logging?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: disable logging</title><link>https://devzone.nordicsemi.com/thread/73417?ContentTypeID=1</link><pubDate>Tue, 17 Jan 2017 11:35:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:772d8274-917b-48f5-9996-3d25d94741ec</guid><dc:creator>Ole Bauck</dc:creator><description>&lt;p&gt;Why are you undefining NRF_LOG_ENABLED? This is probably the reason why it is not working.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: disable logging</title><link>https://devzone.nordicsemi.com/thread/73416?ContentTypeID=1</link><pubDate>Mon, 16 Jan 2017 18:29:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2906e644-108d-4a9b-9344-ee9f3fe55032</guid><dc:creator>Michael Lamming</dc:creator><description>&lt;p&gt;Hi Ole,   SDK 12_2.0.&lt;/p&gt;
&lt;p&gt;Perhaps I am confused about the purpose and correct usage of these two config.h files?&lt;br /&gt;
(Is there a note about correct usage in the documentation somewhere?)&lt;/p&gt;
&lt;p&gt;I have sdk_config.h that contains this fragment:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;//==========================================================
// &amp;lt;e&amp;gt; NRF_LOG_ENABLED - nrf_log - Logging
//==========================================================
#ifndef NRF_LOG_ENABLED
#define NRF_LOG_ENABLED 0
#endif
#if  NRF_LOG_ENABLED
// &amp;lt;e&amp;gt; NRF_LOG_USES_COLORS ... etc
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I am compiling with the C flag -DUSE_APP_CONFIG and I have an app_config.h with these settings:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#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
#define NRF_LOG_DEFERRED 0
#define NRF_LOG_BACKEND_MAX_STRING_LENGTH 128
#define NRF_LOG_USES_TIMESTAMP 0
#define NRF_LOG_TIMESTAMP_DIGITS  10
#define NRF_LOG_USES_COLORS 1
#define NRF_LOG_INFO_COLOR 0
#define NRF_LOG_ERROR_COLOR 2
#define NRF_LOG_DEBUG_COLOR 4
#define NRF_LOG_WARNING_COLOR 7
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: disable logging</title><link>https://devzone.nordicsemi.com/thread/73419?ContentTypeID=1</link><pubDate>Mon, 16 Jan 2017 12:26:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:10f7035c-b90d-471d-a1c9-740404df9771</guid><dc:creator>Ole Bauck</dc:creator><description>&lt;p&gt;Which SDK is this? Do you mean sdk_config.h and not app.config.h?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>