Ask Your Question
1

Is it possible to control the size of log file ?

asked 2015-01-08 09:09:24 -0500

updated 2015-01-08 09:34:29 -0500

I code a very simple CPP node which spam rosout with a lot of ROS_INFO :

ros::Rate r(100.0);
std::string logLine;
for(int i = 0 ; i < 1024 ; ++i)
{
    logLine.append("abcd ");
}

while(ros::ok())
{
    r.sleep();
    ROS_INFO_STREAM(logLine);
}

When I launch this node, I can see both log files "rosout.log" and "my_node_name-stdout.log" growing. When "rosout.log" is around 100Mo, the file is "rolled". A new file called rosout.log.1 is created, an rosout.log continue to be feeded with the ROS_INFO...

Look in the source code of rosout, I understand that this size is hard coded to 100 Mo (this is not a problem).

The problem is with the log file of my node. This file seems to be never splitted.

Is it possible to control the size of this log file ?

I try to understand the rosconsole source code, and this part of the roscpp client library. I guess that writting in the log file is done thanks to Log4CXX. Is it done with a FileAppender ? If yes, where is it instanciated ? And can we configure it in rosconsole.config ?

If I well understoud, roslaunch is responsible of redirecting stdout and stderr into log files (if the node is launched with argument output="log"). Does roslaunch can do file rolling ?

Thanks,

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2015-01-16 08:27:42 -0500

The problem is that roslaunch redirect stdout of the node subprocess to a file.

I proposed a patch PR #551 which correct this problem. In this patch the subprocess's stdout are redirected to a "logging.logger" object. This object contain a RotatingFile Handler. This handler will natively control the size of logged data...

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: 2015-01-08 09:09:24 -0500

Seen: 2,093 times

Last updated: Jan 16 '15