Why in this simple sample, my logs are not written in logfile ? Or Is there a way to control the flushing period of the log files ?
Hello,
The following code is a very simple roscpp node :
#include <ros/ros.h>
#include "std_msgs/String.h"
int main(int argc, char **argv)
{
ROS_DEBUG("Hello Listen DEBUG");
ROS_INFO("Hello Listen INFO");
ROS_WARN("Hello Listen WARN");
ros::init(argc, argv, "listener");
ros::NodeHandle n;
ros::Rate r(1.0);
while(ros::ok())
{
r.sleep();
ROS_INFO("Hello Rate INFO");
}
return 0;
}
I launch this node with the following launch file :
<launch>
<env name="ROSCONSOLE_CONFIG_FILE" value="$(find hello_listen)/launch/rosconsole.config"/>
<node pkg="hello_listen" type="hello_listen_node" name="listen"/>
</launch>
And with the following rosconsole.config :
log4j.logger.ros=INFO
log4j.logger.ros.roscpp.superdebug=WARN
log4j.logger.ros.hello_listen=DEBUG
If Logs are output to screen
In this use case, there is no problem, I launch my node with the following line :
roslaunch --screen hello_listen listen.launch
And I can see the following output on my screen :
process[listen-2]: started with pid [9741]
[DEBUG] [1420702977.006649815]: Hello Listen DEBUG
[ INFO] [1420702977.006703278]: Hello Listen INFO
[ WARN] [1420702977.006713664]: Hello Listen WARN
[ INFO] [1420702978.010808820]: Hello Rate INFO
[ INFO] [1420702979.010663079]: Hello Rate INFO
If Logs are output to a file :
Now, If I launch my node with :
roslaunch hello_listen listen.launch
I can see that the following files are created in my log directory :
aba@aba-PC:~/.ros/log/4436aba2-970a-11e4-8008-0090f5eb88dd$ ll
total 108
drwxrwxr-x 2 aba aba 4096 janv. 8 08:45 ./
drwxrwxr-x 521 aba aba 65536 janv. 8 08:45 ../
-rw-rw-r-- 1 aba aba 0 janv. 8 08:45 listen-2-stdout.log
-rw-rw-r-- 1 aba aba 1713 janv. 8 08:45 master.log
-rw-rw-r-- 1 aba aba 22965 janv. 8 08:45 roslaunch-aba-PC-9771.log
-rw-rw-r-- 1 aba aba 149 janv. 8 08:45 rosout-1-stdout.log
-rw-rw-r-- 1 aba aba 2704 janv. 8 08:45 rosout.log
In the rosout.log file, I can see the "Hello Rate INFO" but not the "Hello Listen XXX". This is normal behaviour because, when I display "Hello Listen XXX", node can't publish to /rosout because the nodehandle is not created. This is well documented here with the following sentence :
Everything enabled is sent to the /rosout topic. Note that until the node is fully started, messages will not be sent, so you may not see initial messages.
But in the same documentation webpage there is in section 2 "Output", the following sentence :
Everything enabled goes into the log file.
So, I guess that in my log folder it should be a file corresponding to my node with all the logs (even data logged before the node handle is instanciated). I have a file called listen-2-stdout.log but this file is empty.
Now, If I kill my node, files are flushed, and listen-2-stdout.log contain everything I Need. (even data logged before the node handle is instanciated).
My question is : Is there a way to control the flushing period of the log files ?
Regards,
I would also like to know if there's any way to flush the stdout file to disk. It's causing me some headaches not being able to see what a node's doing at runtime.
Looks like a perm fix for this is tracked in https://github.com/ros/rosconsole/iss...