What is the difference between sdlog2 & logger?

Does the new logger application “logger” better than sdlog2 ?
Is there any documents or discuss about it?

thank you.

I share this question and wanted to revive this to see if anyone can share insight. A little more background as I understand it:

The rcS specifies the default applications which are run. Looking at this it seems either logger or sdlog2 are called, depending on the hardware version and parameters set. Reiterating the question by @cctsao1008:

  1. What is the difference between the two logging modules?
  2. Is one newer or preferred as the other is slowly retired?

Thank you in advance to whomever can shed light on this.

logger is the new logging module. It allows logging of any uorb topic and is therefore more flexible and elegant.

http://dev.px4.io/advanced-logging.html

sdlog2 is the previous logging method. The messages it logs are hardcoded.

The new format may not be supported by all log analysis tools yet.

http://dev.px4.io/flight_log_analysis.html

Thank you @Nicolas.

The default settings for px4fmu-v2_default used sdlog2. I tried the steps below to switch to using logger, but was not getting any log files generated on the microsd. Simply keeping SYS_LOGGER 0 reverts back to sdlog2, which is working. If anyone knows what step I’m missing, that would be helpful to be able to use the new logger.

  1. Create file on microsd card: /etc/config.txt:

param set SYS_LOGGER 1

  1. Create file on microsd card: /etc/logging/logger_topics.txt:

sensor_combined, 10

  1. Add -e option to logger calls in rcS file:

logger start -b 12 -e

Note: I’ve added the -e option so that logging can happen without requiring arming.

Have you tried to set SYS_LOGGER via QGC directly instead of the config.txt?

For a first test, you can forgo configuring the logging with the logger_topics.txt file. Without that file present, a set of default topics will be logged.

Simply changing the parameter in QGC and rebooting the system works fine for me.

I’m now trying to change parameters via QGC directly, but have two questions:

  1. How can you reboot the system in QGC? If I cycle power it does not save the parameters and so I suspect a reboot is a different process

  2. I want logger to run without requiring pixhawk to be armed. Said differently, log upon power up. Looking at the latest rcS, that means I should also set SDLOG_MODE = 1.

    • I did not find the parameter SDLOG_MODE in QGC
    • I set SDLOG_MODE = 1 via the microsd config.txt, but again no log files appeared

@Nicolas, are you able to use QGC to use logger to begin logging upon power on?
Thanks again for your help on this.

Setting the parameter should survive a power cycle.
Have you removed the config.txt? Maybe that’s causing problems?
Are you able to change other parameters s.t. they survive a power cycle?
Have you reverted to the non-modified rcS? I’d suggest you first get it running with the default behavior.
Have you connected to the console and started the logger manually? Does that start with no errors?

If I recall correctly, I had no problems switching to logger through QGC.

hi @hamid-m

The current px4fmu-v2 config has the logger disabled because of flash space limitations. You need to enable it in https://github.com/PX4/Firmware/blob/master/cmake/configs/nuttx_px4fmu-v2_default.cmake#L116 and probably disable sdlog2.

Thank you @bkueng and @Nicolas, I was able to successfully use logger in by modifying px4fmu-v2_default.

For others trying to make the switch from sdlog2 to logger AND want to log on power up (i.e. regardless of arming status) these are the steps that worked for me:

  1. You need to recompile the firmware, because as noted by @bkueng, the default compiling options exclude logger. Hence, be able to successfully build the code

  2. Modify cmake/configs/nuttx_px4fmu-v2_default.cmake

  • under the “Logging” heading, make sure modules/logger is uncommented
  • comment out other modules you don’t plan on using to avoid flash space errors. For example, I commented out drivers/px4flow, drivers/camera_trigger, modules/local_position_estimator, modules/ekf2, and modules/sdlog2
  1. Add etc/config.txt to the microsd card with the following content:

param set SYS_LOGGER 1
param set SDLOG_MODE 1

Now logger is run on power up and generates log/sess<#>/log001.ulg files.