How to set-up LOG_LEVEL to be able to Debug the esp32?

Hello !

I forgot how to set up LOG Level for the ESP32 to be able to debug.

In ArduinoIDE should be something like this board-> esp32 dev module, tools -> Core debug level -> Verbose. But how to do it in Platformio ?

I’ve read this: https://docs.espressif.com/projects/esp … m/log.html

And I have two problems with it: I can’t follow it, because I don’t understand what a file scope and component scope are and the second thing is that I didn’t do anything like that when I used LOG to debug.

I wrote some lines in void setup() like ESP_LOG_VERBOSE or something like that and it worked. I had also wrote something in platformio.ini.

Now I’ve just add

#define LOG_LOCAL_LEVEL ESP_LOG_VERBOSE
#include "esp_log.h"

at the top of the main.cpp
and

esp_log_level_set("*", ESP_LOG_ERROR);        // set all components to ERROR level
esp_log_level_set("wifi", ESP_LOG_WARN);      // enable WARN logs from WiFi stack
esp_log_level_set("dhcpc", ESP_LOG_INFO);     // enable INFO logs from DHCP client

in void setup() .

And there are no log messages in Serial Monitor.

I am obviously doing something wrong but I am oblivious to what that may be.

2 Likes

You can try to add -DCORE_DEBUG_LEVEL=YOURLEVEL macro to your build_flags, e.g.

[env:lolin32]
platform = espressif32
framework = arduino
board = lolin32
build_flags = -DCORE_DEBUG_LEVEL=5
6 Likes

And do I need to keep the following ?

#define LOG_LOCAL_LEVEL ESP_LOG_VERBOSE
#include "esp_log.h"
esp_log_level_set("*", ESP_LOG_ERROR);        // set all components to ERROR level
esp_log_level_set("wifi", ESP_LOG_WARN);      // enable WARN logs from WiFi stack
esp_log_level_set("dhcpc", ESP_LOG_INFO);     // enable INFO logs from DHCP client

That depends on your needs. Leave them to see what info they provide.

1 Like

They offer no info.
Thank you ! The build flag was what I needed.