<?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>How to enable different log levels and sources?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/53227/how-to-enable-different-log-levels-and-sources</link><description>I am working on a project on the nrf52832 board using mesh SDK v3.2.0 and SDK v15.3. I am trying to troubleshoot an issue with the publish process for BLE mesh, but I am not able to see log messages with any levels other than LOG_LEVEL_INFO and any sources</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 16 Oct 2019 15:40:39 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/53227/how-to-enable-different-log-levels-and-sources" /><item><title>RE: How to enable different log levels and sources?</title><link>https://devzone.nordicsemi.com/thread/215362?ContentTypeID=1</link><pubDate>Wed, 16 Oct 2019 15:40:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bb73d588-3090-430b-9f47-bccdcecd55b4</guid><dc:creator>Billy-IV</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;I would say that thread is incomplete.&amp;nbsp; However, I was able to track down why the expected logs were not printing for me.&amp;nbsp; I would like to compose a more complete answer that can be referenced for others.&amp;nbsp; There are 2 ways to get the desired LOG&amp;#39;s to print.&amp;nbsp; The first is changing LOG_LEVEL_DEFAULT and LOG_MSK_DEFAULT in nrf_mesh_config_core.h to allow the levels and sources you want. See below.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;//lines 207 to 215 of nrf_mesh_config_core.h

/** Default log level. Messages with lower criticality is filtered. */
#ifndef LOG_LEVEL_DEFAULT
#define LOG_LEVEL_DEFAULT LOG_LEVEL_DBG1
#endif

/** Default log mask. Messages with other sources are filtered. */
#ifndef LOG_MSK_DEFAULT
#define LOG_MSK_DEFAULT LOG_GROUP_STACK
#endif&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;The log level is filtered by &amp;quot;lower criticality&amp;quot; meaning a lesser value as determined by the values in log.h shown below.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;//lines 110 to 128 of log.h
/**
 * @defgroup LOG_LEVELS Log levels
 * Defines possible criticality levels for logged messages. This can be used in
 * __LOG_INIT() to filter events by criticality.
 * @{
 */

#define LOG_LEVEL_ASSERT ( 0) /**&amp;lt; Log level for assertions */
#define LOG_LEVEL_ERROR  ( 1) /**&amp;lt; Log level for error messages. */
#define LOG_LEVEL_WARN   ( 2) /**&amp;lt; Log level for warning messages. */
#define LOG_LEVEL_REPORT ( 3) /**&amp;lt; Log level for report messages. */
#define LOG_LEVEL_INFO   ( 4) /**&amp;lt; Log level for information messages. */
#define LOG_LEVEL_DBG1   ( 5) /**&amp;lt; Log level for debug messages (debug level 1). */
#define LOG_LEVEL_DBG2   ( 6) /**&amp;lt; Log level for debug messages (debug level 2). */
#define LOG_LEVEL_DBG3   ( 7) /**&amp;lt; Log level for debug messages (debug level 3). */
#define EVT_LEVEL_BASE   ( 8) /**&amp;lt; Base level for event logging. For internal use only. */
#define EVT_LEVEL_ERROR  ( 9) /**&amp;lt; Critical error event logging level. For internal use only. */
#define EVT_LEVEL_INFO   (10) /**&amp;lt; Normal event logging level. For internal use only. */
#define EVT_LEVEL_DATA   (11) /**&amp;lt; Event data logging level. For internal use only. */&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;The log sources are filtered LOG_MSK_DEFAULT are the sources bitwise ORed together to make LOG_GROUP_STACK from line 106 of the log.h&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;//line 106 of log.h
#define LOG_GROUP_STACK (LOG_SRC_BEARER | LOG_SRC_NETWORK | LOG_SRC_TRANSPORT)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;To alter the sources with this method add another source to the declaration of LOG_GROUP_STACK.&amp;nbsp; To change the log levels increase or decrease the LOG_LEVEL_DEFAULT using the log levels from log.h.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;The second method uses the function LOG_INIT().&amp;nbsp; If starting with example code from nordic semiconductor like the light switch example (which is what I did).&amp;nbsp; This is likely already used in the initialization function.&amp;nbsp; LOG_INIT() overrides the default values used in the first method.&amp;nbsp; The inputs and details for LOG_INIT can be found on line 245 of log.h.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;/**
 * Initializes the logging framework.
 * @param[in] msk      Log mask
 * @param[in] level    Log level
 * @param[in] callback Log callback
 */
#define __LOG_INIT(msk, level, callback) log_init(msk, level, callback)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;quot;msk&amp;quot; is manipulated in the same way as LOG_GROUP_STACK.&amp;nbsp; &amp;quot;level&amp;quot; is manipulated the same way as LOG_LEVEL_DEFAULT.&amp;nbsp; &amp;quot;callback&amp;quot; is usually declared as LOG_CALLBACK_DEFAULT. This will allow the log to automatically initialize to the the correct publishing method if you have change between RTT and UARTE.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to enable different log levels and sources?</title><link>https://devzone.nordicsemi.com/thread/215220?ContentTypeID=1</link><pubDate>Wed, 16 Oct 2019 08:37:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:160c38e0-d345-4175-a18e-a2feee205be5</guid><dc:creator>Mttrinh</dc:creator><description>&lt;p&gt;Hi,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Unfortunately, we don&amp;#39;t have documentation regarding this on Infocenter currently. I suggest you have a look at this &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/30767/mesh-debug-print/121727#121727" rel="noopener noreferrer" target="_blank"&gt;thread&lt;/a&gt;, it points out where you can find the documentation. Search for LOG_LEVEL_DEFAULT in nrf_mesh_config_core.h to change the log level.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>