Arduino cli sketch error logging

Hi, All!
To compile arduino sketch using cli, I create bat file (real path cutted)

\arduino-cli.exe compile -b arduino:sam:arduino_due_x --libraries ...\libraries --warnings default --log-level trace --log-file ...\CompileMsg.log \mysketch.ino >...\CompileMsg.txt

It works, but I can't catch sketch compile error message to file
In log file CompileMsg.log I see this strings
time="2021-05-18T16:39:14+03:00" level=info msg="Config file not found, using default values" (etc)

In CompileMsg.txt
"Sketch uses 44752 bytes (8%) of program storage space. Maximum is 524288 bytes."

But if sketch has errors - message printed in console.
Blink:33:3: error: 'digitalW' was not declared in this scope
digitalW rite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
^~~~~~~~

How can I redirect output from console to log file?

Hi @diakin. The reason for this is that the compiler errors are printed on stderr, but your > redirect syntax only controls stdout.

You can learn about redirecting stderr here:

2 Likes

Thank you very much! It works fine! :+1:

You're welcome. I'm glad if I was able to be of assistance. Enjoy!
Per

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.