0
$\begingroup$

Rosanswers logo

I'm trying to better understand the ROS console and logging. I have two issues -- named logs and stderr logs -- that might have a related root cause.

  • OS: Ubuntu 14.04.4
  • ROS release: indigo

Named Logs

I would like to use a named stream but I never see the named log file in ~/.ros/log as I would expect. Instead I see nodename-2-stdout.log. The documentation for NAMED logs is here but I'm not sure if I'm missing something or it has changed.

I still see the INFO and DEBUG prints in nodename-2-stdout.log from ROS_DEBUG_STREAM_NAMED or ROS_INFO_STREAM_NAMED but no mention anywhere of the name I used. Are these NAMED, INFO and DEBUG prints supposed to end up in a named log file in ~/.ros/log?

STDERR

The Logging Output Documentation describes stderr and stdout to the log file according to the table and text. I only see a node log file appended with stdout.log. stderr (e.g. ERROR) seems to be printed to my rosout.log. Should I have a nodename.log containing stderr and stdout or is my setup somehow configured to only output the node log with stdout output?


Originally posted by roboticom314 on ROS Answers with karma: 107 on 2017-01-03

Post score: 3

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

Using the _NAMED macros create a named log4cxx logger, which adds the name to each log message on rosout and allows you to set the log level for those messages separately, but it's using the same appender and appending to the same log file by default.

I haven't done it myself, but if you can figure out how to configure log4cxx by following the rosconsole configuration you can redirect the output for your named logger to a separate file.

I'm not sure why you're not seeing a stderr log; I believe those are set up by roslaunch, so it may be related to where you're sending the node output from roslaunch. (output="log" vs output="screen") (if you're not using roslaunch, you won't have a stderr log at all)


Originally posted by ahendrix with karma: 47576 on 2017-01-03

This answer was ACCEPTED on the original site

Post score: 0


Original comments

Comment by roboticom314 on 2017-01-05:
I tried output="log" and still don't see the stderr logs. In fact, I can't remember ever seeing stderr logs even with launch files. Any other thoughts there?

Comment by ahendrix on 2017-01-05:
I thought I'd seen stderr written to logs, but I don't have any around, so now I'm not sure that roslaunch actually sends stderr to a separate log at all.

Comment by ahendrix on 2017-01-05:
Note that the logging documentation that you're referring to says that log messages go to stderr, and in POSIX terminology, stdout and stderr traditionally go to the terminal, not a log. See https://en.wikipedia.org/wiki/Standard_streams (stdout goes to a log because roslaunch redirects it there)

Comment by roboticom314 on 2017-01-06:
I have seen in the past mentions of stderr items being written to a log in ~/.ros/log that never seems to exist. I think there is the idea that stderr could be written to a log but there's some implementation detail that's missing.

Comment by CCGreg on 2018-02-15:
This seems related to my issue of not seeing ROS_ERROR calls being logged to a log file. I see a stdout log for each node but no stderr log. All ROS_ERROR output goes to the terminal. I am running Kinetic on a Debian Jessie OS.

Comment by davrsky on 2018-02-16:
Has anyone ever figured out how to get stderr to go to a log file? Right now I'm defaulting to redirecting the output of roslaunch with 2>stderr.log but would be nice if there was an automatic / standardized way of getting it included in the node's log file

Comment by JeremyRoy on 2021-12-06:
For the stderr logging issue, a hacky way of getting it to work is to make the following change to /opt/ros/<ROS_DISTRO>/lib/python<2.7 or 3.*>/dist-packages/roslaunch/nodeprocess.py:

  1. Un-indent line 250: logfileerr = open(errf, mode)
  2. Remove line 249: if is_child_mode():

Now you when you run nodes you should see the <node_name>-stderr.log file in you log directory.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.