Ask Your Question
1

Log rotation in ros

asked 2017-07-27 01:07:52 -0500

MohsenTamiz gravatar image

I am looking for a clean and standard way to have a log rotation in my program. Through this answer I found this PR that mentioned this feature but currently has not merged and does not seem have a plan to merge in the near future. Also by looking at the answer I tried to work with logrotate and with some script like this I wrote a script to rotate my logs (I had to use copytruncate) but there is a annoying problem with this approach.

As this answer mentions there is a conflict between logrotate and log4j, log4j track the position of file and when we truncate it for being compatible unix system adds some null characters before the current position of log and finally we get the same file size and rotation does not mean anything.

I think log rotation is an important feature for a program in a medium scale and above, and I wonder how some big real robot softwares implement this feature and is it possible to run a big project without this feature, I have a limited resource but I hope to able to keep all information that I log during runtime.

Can someone suggest me a solution to this and explain why does not this feature exist in ros log (am I wrong about importance of this feature or not)?

edit retag flag offensive close merge delete

Comments

Could anyone suggest me a starting point for solving this problem?

MohsenTamiz gravatar image MohsenTamiz  ( 2017-07-29 08:42:31 -0500 )edit

Hi Mohsen, have you solved this problem? I'm also facing it.

lucascoelho gravatar image lucascoelho  ( 2017-11-27 13:04:43 -0500 )edit

No I`m still looking for a proper solution of it, currently we just try to log as much as we hope not floating.

MohsenTamiz gravatar image MohsenTamiz  ( 2017-12-09 06:18:10 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2018-02-26 05:53:04 -0500

lucascoelho gravatar image

HI Mohsen,

I've implemented a logrotate script that cleans the ROS log folder and creates tar.gz files for old logs. Make sure you have logrotate installed and place the script inside your /etc/logrotate.d folder. Also, make sure to replace the paths on the logrotate script with your own paths.

https://github.com/lucascoelhof/ros_l...

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2017-07-27 01:07:52 -0500

Seen: 474 times

Last updated: Feb 26 '18