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

Overflow ROS logs in ".ros" dir

asked 2018-08-10 12:02:55 -0500

urpylka gravatar image

updated 2018-08-10 12:31:14 -0500

Hello, I got a problem with overflow ROS logs. For reproducing that I wrote the node:

#! /usr/bin/env python
import rospy
rospy.init_node("SPAM", anonymous=True)
r = rospy.Rate(1000000)
string = "fsafassfaffsadfasf" * 1000
while not rospy.is_shutdown():

And after tests I got the next results:

file list

It turns out, there is we save 250M of logs for each node which however was created. But it is not suitable for me because I have many nodes.

  • Can I resize 50M to another size & change counts of file logs?
  • Can I set up a max size for all .ros directory?
edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2021-08-25 09:38:28 -0500

Jaron gravatar image

updated 2021-08-25 09:39:50 -0500

rospy uses the python logging module underneath and so all your customizations can just be added to the python logger object directly. To get this level of customization for how the log files are written, you should write your own log handler that would probably inherit from the FileHandler class.

Your code would look something like this:

#!/usr/bin/env python

import rospy
import logging


logger = logging.getLogger("rosout")

class CustomFileHandler(logging.FileHandler):
    def emit(self, record):
        # handle logging records, I would check the python documentation linked above
    def close(self):
        # close the file

edit flag offensive delete link more

Question Tools



Asked: 2018-08-10 12:00:55 -0500

Seen: 246 times

Last updated: Aug 25 '21