Arduplane 4.0 - Library Example AP_Logger_test.cpp is not working, no log file generated

I am currently trying to learn how to set up custom log files within the Ardupilot code. I want to be able to manually record the flight sensor data, like the magnetometer orientations, accelerometers, gyroscopes, etc. I started off by building and running the AP_Logger_test.cpp example script on a Pixhawk1, but I got the following output:

Logger Log Test 1.0
TOGCS: Preparing log system
Failed to create log directory /APM/LOGS : ENOSPC
AP_Logger_File: buffer size=16384
TOGCS: Prepared log system
Unable to fetch Log File Size: ENOSPC
Log open fail for /APM/LOGS/00000001.BIN - ENOSPC
Log open fail for /APM/LOGS/00000001.BIN - ENOSPC
Using log number 0
Writing to flash… wait…
Successfully mounted SDCard (slowdown=0)
Average write time 0.1 usec/byte
Testing Write
Testing WriteCritical
Test complete.

No log file was generated, and it looks like the logger failed to open a log file on the sd card. I am not exactly sure what is wrong or how to fix it. I also tried it on a Pixhawk 4 with the same result Does anyone know how to get this code to work, or have any advice on how to record the sensor data in a log file? Thanks

@peterbarker this is probably one for you

Update on my project:

Still don’t know why the library example doesn’t work, but I found a different method for writing plain files on the Pixhawk1 with Ardupilot using the posix_compat.h from the AP_Filesystem library. Adding these lines of code to my script:

#include <AP_Filesystem/posix_compat.h>

APFS_FILE *f = apfs_fopen("test.txt", "a");

I was able to write a text file test.txt containing the string “Hello” to the sd card. While this isn’t the same as using the logging system demonstrated in the library example AP_Logger_test.cpp, this might actually serve my purposes better rather than trying to work with the logger data. I know that the flight data logging works fine with ArduPlane, so if someone figures out what is wrong with the library example, I’d be interested to know.


Hello Samuel,

Did you get an answer for you problem with AP_logger_test.cpp ?

Actually, I get kind of the same issue and posted about it.

In my case, the file is created in the ‘logs’ directory but stays empty.

Anyway, if you had some progress on the Logger since the time of your last post, let me know :slight_smile:


No, I never got an answer, but the solution that I outlined in my previous post actually served my needs better. It doesn’t follow the same system as the ardupilot log file, but it is a more basic way of writing data to a file, which is all i wanted to do for my project.