How disable log esp32 using platform io ide

I moved from esp-idf 1.2.0 to 2.0.0 in platformIO . In version esp-idf 1.2.0, i can config log level in file sdkconfig.h

But in version esp-idf 2.0.0 (newest), do not have file sdkconfig.

I try add line build_flags = -DCORE_DEBUG_LEVEL=0 into file platformio.ini but can not disable log infor.
Hope someone can help me.

This line is for Arduino-ESP32, not ESP-IDF.

PlatformIO doesn’t have ESP-IDF 2.0.0, you mean maybe the platform-espressif32 version that is now 2.0.0. And that has ESP-IDF v4.1.

See Espressif’s documentation for setting the log level.

How to disable log for esp-idf

It seems that
build_flags = -DCORE_DEBUG_LEVEL=x
in file platformio.ini does NOT affect “C” source files, only “CPP” ones.
In my IDE (see details at the end) it seems that ony “E” level are shown in “C” files. If you use LOGV it won’t be seen evend configuring DCORE_DEBUG_LEVEL=5
In CPP files all is fine.

In Redirecting... they speak about “CPPDEFINES”

In my case I have a mix of C and CPP files. Anyone knows how to manage LOG levels in C files?

$ pio update
Updating platformio/contrib-piohome 3.3.1 @ ~3.3.1 [Up-to-date]
Updating platformio/contrib-pysite 2.38.191020 @ ~2.38.0 [Incompatible 2.39.201019]
Updating platformio/tool-unity 1.20500.200612 @ ~1.20500.0 [Up-to-date]
Updating platformio/tool-scons 4.40001.0 @ ~4.40001.0 [Up-to-date]
Updating platformio/tool-cppcheck 1.210.0 @ ~1.210.0 [Incompatible 1.230.0]

Platform Manager

Platform espressif32

Updating platformio/espressif32 2.1.0 [Up-to-date]
Updating platformio/toolchain-xtensa32 2.50200.80 @ ~2.50200.0 [Up-to-date]
Updating platformio/toolchain-esp32ulp 1.22851.191205 @ ~1.22851.0 [Up-to-date]
Updating platformio/framework-arduinoespressif32 3.10004.201016 @ ~3.10004.191002 [Up-to-date]
Updating platformio/tool-esptoolpy 1.30000.201119 @ ~1.30000.0 [Up-to-date]
Updating platformio/tool-openocd-esp32 2.1000.20201202 @ ~2.1000.0 [Up-to-date]
Updating platformio/tool-mkspiffs 2.230.0 @ ~2.230.0 [Up-to-date]
Updating platformio/tool-cmake 3.16.4 @ ~3.16.0 [Up-to-date]
Updating platformio/tool-ninja 1.7.1 @ ^1.7.0 [Up-to-date]

Full platformio.ini?

Thanks max.

This is my ini file:

platform = espressif32
board = esp32dev
framework = 
lib_deps = 
	adafruit/Adafruit BME280 Library@^2.1.2
	adafruit/Adafruit SSD1306@^2.4.2
	adafruit/Adafruit BusIO@^1.7.1
upload_port = /dev/ttyUSB0
monitor_speed = 115200
build_flags = -DCORE_DEBUG_LEVEL=3

; #define ARDUHAL_LOG_LEVEL_NONE       (0)
; #define ARDUHAL_LOG_LEVEL_ERROR      (1)
; #define ARDUHAL_LOG_LEVEL_WARN       (2)
; #define ARDUHAL_LOG_LEVEL_INFO       (3)
; #define ARDUHAL_LOG_LEVEL_DEBUG      (4)

description = Touch pad controlled thermostat with OLED display and 455MHz trasmitter.

Not reproducable.


platform = espressif32
board = esp32dev
monitor_filters = esp32_exception_decoder
framework = arduino
monitor_speed = 115200
build_flags = -DCORE_DEBUG_LEVEL=3

and main.cpp

#include "Arduino.h"

extern "C" {
void test_log_c(); /* from test.c */

void setup()
    printf("Start of firmware\n");
    log_i("Test log level information from C++");
    log_v("Test log level verbose from C++");

void loop()

and src/test.c

#include <esp32-hal-log.h>

void test_log_c() {
    log_i("Test log level information from C");
    log_v("Test log level verbose from C");

as one can see in the execution log

Start of firmware
[I][main.cpp:10] setup(): Test log level information from C++
[I][test.c:4] test_log_c(): Test log level information from C

there is no difference between C and C++ files, both behave the same. Info logs go through while debug and verbose logs don’t, since they’re compile-time removed.

Through a “Verbose Build”, one can also see that both compiler invocations have the -DCORE_DEBUG_LEVEL=3 flag.

Thanks again Max.

I was using “esp_log.h” and the macros ESP_LOGx

And indepently of platformio.ini, only ESP_LOGE was be seen on the monitor port:
E (170) Touch pad: LOGE test

BUT, if I maintain the previous macros and add yours…
log_e("log_e test");
log_w("log_w test");
log_i("log_i test");
log_d("log_d test");
log_v("log_v test");

I can see all the logs (ESP_LOGx and log_x):
[E][touchpad.c:80] initializeTouchPad(): LOGE test
[W][touchpad.c:81] initializeTouchPad(): LOGW test
[I][touchpad.c:82] initializeTouchPad(): LOGI test
[E][touchpad.c:87] initializeTouchPad(): log_e test
[W][touchpad.c:88] initializeTouchPad(): log_w test
[I][touchpad.c:89] initializeTouchPad(): log_i test

As you can see the ESP_LOGx syntax is lost (TAG not shown).

Anyway, thanks for your help, I will use log_x and the
#include <esp32-hal-log.h>
instead of
#include “esp_log.h”

That file does get included by esp32-hal-log.h though

And those same macros are available, and should behave the same. esp_log.h seems to be the low-level component that does the actual logging, but esp32-hal-log.h is one layer above and compile-time deactivates those macros or functions.