ros_comm icon indicating copy to clipboard operation
ros_comm copied to clipboard

roslaunch: option to disable all logging to file system

Open tfoote opened this issue 12 years ago • 22 comments

I have an embedded computer on the robot which runs off of an SD card. It is highly desirable to be able to disable output to the file system, notably logging, but ROS does not support this.

Please see discussion at http://answers.ros.org/question/594/how-can-i-completely-disable-writing-logs-to

It seems that rosconsole, rospy, roscpp, and rosout all need to be modified, but I don't really understand.

trac data:

  • Owner: straszheim
  • Reporter: veltrop
  • Reported at: Sun Apr 3 22:57:55 2011
  • URL: https://code.ros.org/trac/ros/ticket/3438

tfoote avatar Jan 31 '13 19:01 tfoote

[kwc] It appears there are some issues fully disabling logging, but you can greatly reduce with:

rosconsole.config: replace INFO/WARN with FATAL

python_logging.config: replace DEBUG with CRITICAL

If you want to disable roslaunch logging, use the attached patch.

tfoote avatar Jan 31 '13 19:01 tfoote

[veltrop] Excellent, the roslaunch logging patch is very helpful.

tfoote avatar Jan 31 '13 19:01 tfoote

[veltrop] Followed your steps, plus recompiled everything with this in my $ROS_ROOT/rosconfig.cmake: set(ROS_BUILD_TYPE MinSizeRel) set(ROS_COMPILE_FLAGS "-DROSCONSOLE_MIN_SEVERITY=5 ${ROS_COMPILE_FLAGS}")

I still get logging that begins with [roscpp_internal] and [DEBUG]

tfoote avatar Jan 31 '13 19:01 tfoote

[kwc] Right, that's one the issues I'm referring to. It appears that the roscpp_internal logger may not work with the config file, but I need to investigate more before filing a separate ticket.

tfoote avatar Jan 31 '13 19:01 tfoote

[kwc] transferring ticket to troy to look at. The basic issue is: "how do I disable logging of the roscpp_internal logger". After some basic experiments with the logging config file, I'm not sure this logger is respecting the external configuration.

tfoote avatar Jan 31 '13 19:01 tfoote

[straszheim] compile with ROSCPP_LOG_DISABLE defined to disable the roscpp_internal logger completely. In r13673. Leaving ticket open pending confirmation that this does the trick...

tfoote avatar Jan 31 '13 19:01 tfoote

[straszheim] ROSCPP_LOG_DISABLE is gone. In r13691 ROSCPP_LOG_DEBUG has been converted:

#define ROSCPP_LOG_DEBUG(...) \ ROS_DEBUG_NAMED("roscpp_internal", VA_ARGS)

Note that rosout depends on some file_log path calculating stuff, looks like some more detangling could be in order.

leaving ticket open. Veltrop, does this work for you?

tfoote avatar Jan 31 '13 19:01 tfoote

Any update to this? I have the same requirement (for the same reason). I do like output to console so disabling logging levels is not an acceptable solution for me. I only want to disable logging to filesystem. Is it possible without recompiling anything?

protobits avatar Oct 13 '15 17:10 protobits

As far as I can see from this issue, the linked ros answers question, and my experience, I'd say no there is no way to do this still. It will likely require a pull request to get the ball moving on this type of feature.

wjwwood avatar Oct 13 '15 17:10 wjwwood

The ticket is marked with the milestone untargeted which states:

It is unlikely that the maintainers will have time to address these issues. Please provide pull requests if you want these issues to be addressed.

dirk-thomas avatar Oct 13 '15 17:10 dirk-thomas

Ok, thanks for clearing up the state of this issue.

I was wondering if this could be achieve by simple using a particular log4cxx configuration in the corresponding file. I don't have much experience with log4cxx to understand if it is possible or not (or if it would require particular implementation to handle it).

On Tue, Oct 13, 2015 at 2:39 PM, Dirk Thomas [email protected] wrote:

The ticket is also marked with the milestone untargeted which states:

It is unlikely that the maintainers will have time to address these issues. Please provide pull requests if you want these issues to be addressed.

— Reply to this email directly or view it on GitHub https://github.com/ros/ros_comm/issues/139#issuecomment-147787963.

protobits avatar Oct 13 '15 17:10 protobits

You can call the following function to completely shutdown the ROS logging system (independently on which backend is being used for logging):

ros::console::shutdown();

For existing binaries you can provide a custom rosconsole configuration file:

  • set the env variable ROSCONSOLE_CONFIG_FILE to point to your custom file

  • create a rosconsole configuration file containing the following:

    log4j.threshold=OFF
    

See the API documentation of log4cxx for more information.

dirk-thomas avatar Dec 10 '15 19:12 dirk-thomas

Added the same information to the rosconsole wiki page.

dirk-thomas avatar Dec 10 '15 19:12 dirk-thomas

Since the requirement was to disable only filesystem logging and not all the logging (i.e. leave output to console working), shouldn't this be left open?

protobits avatar Dec 10 '15 19:12 protobits

This thread is mostly about rosconsole and it does not explicitly log to the file system.

Can you please describe your use case again?

dirk-thomas avatar Dec 10 '15 19:12 dirk-thomas

Ok, I understand my use case was the same as the original poster due to the title (disable logging to filesystem). In my case I thought it would be useful to have output to console while disabling output to filesystem, since the cost of logging to filesystem may be high (in my case, an Odroid computer with an SD card).

On Thu, Dec 10, 2015 at 4:32 PM, Dirk Thomas [email protected] wrote:

This thread is mostly about rosconsole and it does not explicitly log to the file system.

Can you please describe your use case again?

— Reply to this email directly or view it on GitHub https://github.com/ros/ros_comm/issues/139#issuecomment-163726973.

protobits avatar Dec 10 '15 19:12 protobits

How are you starting the software which write to the filesystem? Is it about the logging of roslaunch ?

dirk-thomas avatar Dec 10 '15 19:12 dirk-thomas

I use roslaunch to launch a node which uses ROS_INFO_STREAM. I can see several log files created in .ros/log. The worst is rosout.log which grows rapidly. I can see it contains all msgs printed to console. I tried setting output="screen" for this node in the roslaunch file and also using --screen for roslaunch and I still see rosout.log being updated. Only way to disable this is to reduce the logging level but this also disables output to screen.

On Thu, Dec 10, 2015 at 4:36 PM, Dirk Thomas [email protected] wrote:

How are you starting the software which write to the filesystem? Is it about the logging of roslaunch ?

— Reply to this email directly or view it on GitHub https://github.com/ros/ros_comm/issues/139#issuecomment-163728066.

protobits avatar Dec 10 '15 19:12 protobits

I have update the title to clarify the scope of the requested feature.

When the launch file specifies output="screen" for a node it does not log the output of the node to a file. I confirmed that by running roslaunch roscpp_tutorials talker_listener.launch. A log file is still being generated but it only contains information about the environment and spawned processes (cat ~/.ros/log/latest/roslaunch-drudge-<PID>.log). No logfiles fot the nodes are being created (e.g. ~/.ros/log/latest/talker*.log).

The same works for me when passing --screen to roslaunch (both with Indigo).

The logfile containing the process information is pretty short and should grow over time (even nodes are not continuously restarted). It is currently not possible to disable that. But it sounds like that is not your problem.

Which version of ROS are you using? Maybe you want to try the tutorial example I used or share a minimal reproducible example which has the problem for you?

dirk-thomas avatar Dec 10 '15 19:12 dirk-thomas

I'm using indigo. It also seems strange to me this does not work. I will try and report back.

protobits avatar Dec 10 '15 20:12 protobits

Hi, could someone please give me an update on this topic please?

pmirabel avatar Jan 14 '21 14:01 pmirabel

Hello everybody!

I have been also stucked for a day within this topic :sweat_smile: but now is crystal clear for me. I am using ROS Noetic.

  1. export ROSCONSOLE_CONFIG_FILE=/path/to/your/custom/config/file works like a charm.
  2. The content of your /path/to/your/custom/config/file must be log4j.threshold=OFF in order to disable the ROS logging facility.
  3. Now the tricky part for me. It is of paramount importance remember that disabling ROS log does not disable standard output. That means every single std::cout you have in your code will be placed into your (typically) $HOME/.ros/log inside the given node folder. When roslaunch --screen is enabled, standard output will prompt the terminal, so no std::cout logs will be stored in disk (or SD card). But when --screen is not enabled, std::cout will be stored into disk.

For me, the key point is realize that disabling ROS logging facility does not stop standard output as std::cout :muscle:

Hope this post will help somebody :crossed_fingers:

Thank you!

mmmherma avatar Mar 24 '22 12:03 mmmherma