I am not able to set log level dynamically within app

Hi,

I'd like to set log level within the app but without success. I am browsing through https://docs.nordicsemi.com/bundle/ncs-2.5.2/page/zephyr/services/logging/index.html but I am not sure what I am doing wrong.

I have a 9161 based custom board which uses RTT and also redirects console to uart2 as follows:

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
/dts-v1/;
#include <nordic/nrf9161ns_laca.dtsi>
#include "msdk1_nrf9161_common.dtsi"
/ {
chosen {
zephyr,flash = &flash0;
zephyr,sram = &sram0_ns;
zephyr,code-partition = &slot0_ns_partition;
zephyr,console = &uart2;
zephyr,uart-console = &uart2;
};
};
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

My prj.conf:

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#
# Copyright (c) 2020 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#
CONFIG_CLOCK_CONTROL=y
#### "debugging" ##########################################
### debug network timing
# CONFIG_NET_LOG=y
### debug MQTT timing
# CONFIG_MQTT_LOG_LEVEL_DBG=y
### debug optimizations (-Og)
CONFIG_DEBUG=y
CONFIG_DEBUG_OPTIMIZATIONS=y
CONFIG_DEBUG_THREAD_INFO=y
### to try to debug unwanted soft resets (n=not resetting):
### debugging threads
# CONFIG_THREAD_ANALYZER=y
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Initialisation:

LOG_MODULE_REGISTER(main, LOG_LEVEL_DBG);

When I am trying to do, for example:

log_filter_set(NULL, 0, CONFIG_LOG_DOMAIN_ID, LOG_LEVEL_ERR);
I observe the default logging behavior without change.
Big thanks in advance for any help.