This blog is to describe how to use the Nordic nRF5 SDK to include the logger module and how to use the CLI interface for send command through BLE / UART / RTT to configure the log module, basic operation of peripheral such as LED on/off, flash dump log.

Also, the Flash logger backend (one of new excellent debugging feature) is introduced on the SDK 15.3. It is used to store logs in non-volatile memory.


What is the logger module??

The logger module provides logging capability for your application. It is used by SDK modules and can be also used in the application code.

Main features of this library are:

  • Four severity levels – ERROR, WARNING, INFO, and DEBUG.
  • Formatted string (printf-like) log format.
  • Dedicated macro for dumping data.
  • Configurable global severity level.
  • Independent severity level for each module.
  • Enabling and disabling logging per module and globally.
  • Filtering on module instance level.
  • Optional timestamping with time formatting.
  • Optional coloring of the logs for different modules and different severity levels.
  • Prefixing log entries with the module name or instance name, and severity.
  • Deferring of log processing to idle stage.
  • Logging mechanism decoupled from the logger backend.
  • Multiple backends supported.
  • Several backends provided: RTT, UART, console (Command Line Interface), flash (see Flash logger backend).
  • Optional dynamic (run time) filtering on module and instance basis.
  • Storing and loading logger configuration by using Flash Data Storage.

What is the CLI (Command Line interface) ?

This module allows to create and handle a command line interface (CLI) with a user-defined command set. You can use it in examples where more than button/LED user interaction is required. This module can be considered a Unix-like command line interface with these features:

  • Support for multiple instances.
  • Advanced cooperation with the Logger module.
  • Support for static and dynamic commands.
  • Smart command completion with the Tab key.
  • Built-in commands: clearclicolorsechohistory and resize.
  • Viewing recently executed commands using the Up/Down keys.
  • Text edition using Left/Right/End/Home/Insert keys.
  • Support for ANSI escape codes: VT100 and ESC[n~ for cursor control and color printing.
  • Support for multiline commands.
  • Built-in handler to display help for the commands.
  • Support for wildcards.
  • Support for meta keys.

The module can be connected to any transport. At this point, the following transport layers are implemented:

  • Bluetooth
  • UART
  • Experimental libUARTE. This backend is recommended when the CLI must exchange big amounts of data fast, for example when CLI is used with a script.
  • RTT

SDK Example: Experimental: Console over Bluetooth Application

The Command Line Interface over BLE (CLI BLE) Application is an example that showcases how BLE NUS (Nordic UART service) can be used as a transport for a console. [Link]

The example folder contains a Python script that uses the PC BLE driver and an additional board to connect to the example and forward any BLE NUS traffic to a network port. A standard terminal, such as PuTTY, can be used to connect to a network port and run the console.


Perform the following steps to test the CLI BLE Application:

Step 1: Install nrfutil:

pip install nrfutil

Step 2: Compile and program the application. Observe that the BSP_INDICATE_ADVERTISING state is indicated.

Step 3: Start the script, for example: --snr 682844863 --name Nordic_CLI --com COM53 --family NRF52

Step 4: Open a terminal, for example PuTTY. Set the Connection Type to Raw and the Destination Address to


In this example, it sends the LED on/off command to turn on/off the LED at the nRF52 DK board. Also, it can read some particular flash log through CLI (UART or BLE) terminal.

Meanwhile, you can use the CLI over UART on the DUT for sending the command.


  • Python version : Python 2.7.x
  • IDE : Segger Embedded Studio
  • NRF52832 DK / NRF52840 DK

More detail description on the flash backend can be found at.

CLI command for the flash backend

NRF_CLI_CMD(clear,   NULL, "Remove logs",      flashlog_clear_cmd),
NRF_CLI_CMD(read,    NULL, "Read stored logs", flashlog_read_cmd),
NRF_CLI_CMD(status,  NULL, "Flash log status", flashlog_status_cmd),