This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How can I use Log4View to display the log output from RTT?

I wanted to share the most reliable and efficient method I found to collect and store my log outputs through segger RTT, which also allows using the excellent Log Viewer Log4View, in order to display the segger RTT output from NRF52. It ends up simply creating and launching 2 distinct batch files, starting Log4view and enjoy debugging!

The first batch file starts the "JLINK Commander" that reliably connects (and reconnects after a new firmware flashing) to a target, making the log output available through telnet. I called it "jlinkcommander.bat" and should be started once only;

REM this is to start JLINK Commander, that collects log stuff and make it available through telnet port 19021
"C:\Program Files (x86)\SEGGER\JLink_V510d\JLink.exe" -device NRF52832_XXAA -if SWD -speed 4000 -autoconnect 1

The 2nd batch file can be killed and restarted as desired to "cut" the log file, and store the previous log as an archive, which can be useful for later reference. I called it "jlink_startlog.bat" :

REM this script renames current log file, if any, to date-time format
REM then move all logs to subfolder archive
REM then starts a telnet receiver to localhost + stores output to a local file
REM this file can then be read through Log4View (file receiver, log format = pattern, %m (dump all directly)
REM Log4View could also be configured to track formatting like  UniversalTime (runtime in ms) log source, etc..
@echo off
echo wscript.echo year(date) ^& "-" ^& right(100+month(date),2) ^& "-" ^& right(100+day(date),2)^& "@" ^& right(100+hour(time),2) ^& "-" ^& right(100+minute(time),2) > "%temp%\dateparts.vbs"
for /f "tokens=1 delims=" %%a in ('cscript //nologo "%temp%\dateparts.vbs"') do set yyyymmddhhmm=%%a
echo Now you can use this in your filename: %yyyymmddhhmm%
@echo on

if EXIST rtt_debug.log (
REN rtt_debug.log "%yyyymmddhhmm% - rtt_debug.log"
)

move %~dp0\*.log %~dp0\archive

telnet localhost 19021 -f rtt_debug.log

Finally I am viewing the log output using Log4View. Simply configure a File Receiver, using the pattern %s to output the whole file content. I also standardized the output format of all my NRF_LOG() to feed the uptime in millisecond, the log source, the severity, etc.

[31761132] RFN0 >> [ForcedRxLoad] ignore
[31761134] RFN0 >> [RxProcessRun] <<< scan >>> FreqBandIsmRxDefaultOverride
[31770625] MODEM>> RX (12)
[31770626] MODEM>> 0000: 44 00 00 06 6B 17 01 00 00 00 22 EE -- -- -- -- 
[31770627] MODEM>> [ATRspProcess] app -> h_OnIpTunnelDataReceived (12)

I figure this could end up being made available widely by Nordic, as well as a standard output format by NRF_LOG lib to better take in charge the advanced capabilities of Log4View!

Related