ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
18

How can I completely disable writing logs to filesystem?

asked 2011-04-03 02:14:50 -0600

updated 2011-04-03 17:10:58 -0600

I don't want logs written to the filesystem. The system is an embedded robot platform (Roboard) running from an SD card, ideally the filesystem would be mounted read only. I also don't want to divert the logs to a ramfs.

I still would like to use rxconsole and the 'live' logging facilities though.

From what I gathered on ROS answers I should look at the $ROS_ROOT/config directory.

For rosconsole.config: I looked at http://www.ros.org/wiki/rosconsole and it appears that one can compile out logging but does that kill the rxconsole facility then? The 5 logging levels described there don't include a NONE. But when I put NONE into the rosconsole.config, roslaunch reports that no logging facilities are available (good) but then dumps all logs of all levels to the console (bad)

For python_logging.conf According to http://www.ros.org/wiki/rospy/Overvie... I should look at http://docs.python.org/library/loggin... but I am not clear of how to disable things. I tried deleting the loggers declared in this config file, and changing their levels to be quieter, but neither seemed to have any effect.

Last ditch effort to blackhole the log directory to /dev/null of course failed ;)

edit retag flag offensive close merge delete

Comments

Which solution did you end up using? Also, if you filed a ticket, could you post a link to it?
Asomerville gravatar image Asomerville  ( 2011-05-05 08:48:03 -0600 )edit

I used Daniel Stonier's suggestion.

veltrop gravatar image veltrop  ( 2015-05-07 22:28:49 -0600 )edit

9 Answers

Sort by » oldest newest most voted
7

answered 2011-04-03 14:51:44 -0600

Daniel Stonier gravatar image

updated 2011-04-03 17:05:59 -0600

Hrm, I think it might still need some effort to completely disable everything (as jack suggested, be sure to write a ticket if you wish), but here are some things you can play around with:

No Rosout

Start with 'rosmaster --core' instead of 'roscore'. This avoids firing up rosout.

Cpp Logging

Create an empty $ROS_ROOT/rosconfig.cmake and add the empty line

set(ROS_COMPILE_FLAGS "-DROSCONSOLE_MIN_SEVERITY=5 ${ROS_COMPILE_FLAGS}")

(note ROSCONSOLE_MIN_SEVERITY_NONE = 5 as defined in rosconsole/include/ros/console.h) and then recompile everything. This should disable all your cpp loggers. There is an exception though - the roscpp_internal named logger bypasses this as it seems it uses the log4cxx logger interfaces directly. I actually can't seem to change that logger's level (also roscpp.superdebug) at all via the rosconsole.config file, but that is a separate problem.

Python Logging

If you delete ${ROS_ROOT}/config/python_logging.conf, python programs will just completely abort any logging. I don't know that this is the recommended way of doing it though ;)

Conclusions

So, in conclusion, looks like it might be possible to disable everything, just roscpp might need a better look at so you can disable those two named internal loggers.

However, this doesn't address your initial query - i.e. how to disable file logging whilst maintaining rosout topics. That would, I suspect, require a change in the architecture of the logging system.

Possible Solutions

If you really want to be minimal, then escape the overhead of the ros logging architecture completely by disabling things as above. Write a couple of your own topics that do publishing work only publish when there's a subscriber.

If not, then like any framework, its probably easier to find ways to work with it than fight it. Use a small ramdisk reserved for logging, or if possible, while developing, have a usb port with which you can plug a pen drive into. Either point your config and log directories there or create a union filesystem.

The last alternative is to request an overhaul of rosconsole, rospy and rosout so that they don't write to file on request. This would enable debugging output locked only on the rosout topics. Which, is not exactly an unreasonable idea for read only embedded systems.

edit flag offensive delete link more

Comments

I think I will kill the logging architecture as you suggested. Back to printf() for me :( It would make sense for rosconsole etc to have the option of disabling file output.
veltrop gravatar image veltrop  ( 2011-04-03 17:15:34 -0600 )edit
2

Has there been any updates to this since 2011? A more straight forward solution?

Raptor gravatar image Raptor  ( 2014-03-20 03:28:49 -0600 )edit
3

answered 2013-07-31 17:09:33 -0600

rannick gravatar image

Just point it to /dev/shm.

This is a shared memory mount available on most linux boxes.

export ROS_LOG_OUT=/dev/shm/rosLogs

edit flag offensive delete link more

Comments

I didn't want to use a ramfs. I was running an embedded 1ghz 486, with 256mb ram (Roboard). Every kilobyte of ram counted, every CPU cycle precious, memory copies are a big waste.

veltrop gravatar image veltrop  ( 2015-05-07 22:25:19 -0600 )edit
2

answered 2011-04-04 02:23:46 -0600

updated 2011-04-04 02:25:30 -0600

Maybe a "/dev/null-like" filesystem, mounted on $ROS_LOG_DIR, would be a solution. There was a discussion on the kernel mailing list on that topic. I tried nullfs, but without luck.

edit flag offensive delete link more
1

answered 2011-04-03 07:32:40 -0600

Eric Perko gravatar image

How about setting the ROS_LOG_DIR environment variable? According to the docs, that controls where ROS outputs logs to. I'd assume setting that to /tmp or /dev/null should work for you.

edit flag offensive delete link more

Comments

As I said, /dev/null wasn't helpful. It complains that the log directory can't be created, and refuses to run.
veltrop gravatar image veltrop  ( 2011-04-03 16:34:44 -0600 )edit
But changing it to /tmp worked for me, it's not the solution the OP was asking but it might be a valid solution for someone else.
Victor Lopez gravatar image Victor Lopez  ( 2011-07-11 23:28:34 -0600 )edit
1

answered 2013-01-17 02:50:35 -0600

Janis gravatar image

Exactly the same problem here. We are going to create a sshfs and force logging to go to remote box.

edit flag offensive delete link more
1

answered 2016-02-06 17:13:39 -0600

PiotrOrzechowski gravatar image

Thanks to Daniels accepted answer, I figured out a way to disable log output on ros jade (without compiling ros by yourself).

The rosconsole.cmake did not help, but setting the compile flag in my (package or workspace) CMakeLists.txt is actually working:

set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DROSCONSOLE_MIN_SEVERITY=5")

As he also points out, the severity level is set in rosconsole.h:

#define ROSCONSOLE_SEVERITY_DEBUG 0
#define ROSCONSOLE_SEVERITY_INFO 1
#define ROSCONSOLE_SEVERITY_WARN 2
#define ROSCONSOLE_SEVERITY_ERROR 3
#define ROSCONSOLE_SEVERITY_FATAL 4
#define ROSCONSOLE_SEVERITY_NONE 5

No more log console prints and file output on Release platforms :)

edit flag offensive delete link more
1

answered 2011-04-03 13:35:34 -0600

joq gravatar image

Seems like a reasonable question. If there is no direct support, please open an enhancement ticket.

Meanwhile, as a work-around, how about setting the minimum severity to FATAL? There should not be many of those.

edit flag offensive delete link more

Comments

I don't want the logs minimized. I want them to be nonexistent.
veltrop gravatar image veltrop  ( 2011-04-03 16:37:08 -0600 )edit
1

answered 2021-03-16 08:14:49 -0600

130s gravatar image

updated 2021-03-16 09:16:35 -0600

This is an old thread but I'm still posting because almost/all answers look to either require hack to some extent, or less sufficient.

In 2015 a section was added to rosconsole wiki page about disabling all logging where you can see (as of 2021/03) disabling without a hack by config (log4j.threshold=OFF) or by C++ code (ros::console::shutdown()).

edit flag offensive delete link more
0

answered 2015-11-24 05:09:22 -0600

BobV gravatar image

For me, issuing the following command after startup works:

yes | rosclean purge

The logging directory is cleaned and there does not appear to be any file logging any more. ROS still runs and does not even issue a warning.

edit flag offensive delete link more

Comments

rosclean purge -y, no need to pipe yes.

Humpelstilzchen gravatar image Humpelstilzchen  ( 2016-02-07 02:42:03 -0600 )edit

Question Tools

3 followers

Stats

Asked: 2011-04-03 02:14:50 -0600

Seen: 22,034 times

Last updated: Mar 16 '21