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

Log scheduling and archival policy in ROS

asked 2017-02-24 17:15:59 -0500

can-43811 gravatar image

I am looking for log archival package which should be able to help me in based on below policy. (1) whenever log file (system.log) size >30859 or file is 3 day old then it should archive the same with new name system.log1 and again start the feeding the log in system.log file from start after truncating its content. I am going to write all the debug statements in log file through ROS c++ code in linux environment. Any immediate help will be appreciated.

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted

answered 2017-02-27 16:29:00 -0500

On Linux, a flexible solution is logrotate

It allows logs to be archived based on age and/or size; archives logs may be compressed; versions may be capped: etc

When using log rotate on a running system which is not coded to handle its log files being closed/moved by an external process, use the copytruncate option as it will preserve the open file handle(s) being used by other programs.

edit flag offensive delete link more

answered 2017-02-27 12:18:35 -0500

ahendrix gravatar image

ROS doesn't provide any ROS-specific log-rotation facilities.

roscpp uses log4cxx as the logging framework, so you may be able to write a log4cxx configuration that specifies log rotation. (I don't know much about log4cxx but that seems like a feature it should have)

There are also a substantial number of linux tools that can do this, so perhaps one of those would be appropriate for your use case.

If you find an appropriate linux tool and want to use it from within a launch file, you may be able to write a wrapper script that you can use with the roslaunch launch-prefix.

edit flag offensive delete link more

Question Tools



Asked: 2017-02-24 17:15:59 -0500

Seen: 391 times

Last updated: Feb 27 '17