Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions source/Releases/Release-Galactic-Geochelone.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,18 @@ It is now possible to specify different logging levels for different loggers on
The above command sets a global log level of WARN, but sets the log level of the talker node messages to DEBUG.
The ``--log-level`` command-line option can be passed an arbitrary number of times to set different log levels for each logger.

Ability to configure logging directory through environment variables
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

It is now possible to configure the logging directory through two environment variables: ``ROS_LOG_DIR`` and ``ROS_HOME``.
The logic is as follows:

* Use ``$ROS_LOG_DIR`` if ``ROS_LOG_DIR`` is set and not empty.
* Otherwise, use ``$ROS_HOME/log``, using ``~/.ros`` for ``ROS_HOME`` if not set or if empty.

Thus the default value stays the same: ``~/.ros/log``.

Related PRs: `ros2/rcl_logging#53 <https://github.com/ros2/rcl_logging/pull/53>`_ and `ros2/launch#460 <https://github.com/ros2/launch/pull/460>`_.

Changes since the Foxy release
------------------------------
Expand Down
70 changes: 70 additions & 0 deletions source/Tutorials/Logging-and-logger-configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,76 @@ Over time you will see output from various log calls with different properties.
To start with you will only see output from log calls with severity ``INFO`` and above (``WARN``, ``ERROR``, ``FATAL``).
Note that the first message will only be logged once, though the line is reached on each iteration, as that is a property of the log call used for that message.

Logging directory configuration
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's probably worth mentioning here that this feature is only available since Galactic, since this tutorial is generically applying to all distros. (cc/ @maryaB-osr does that sound right?)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I added a note in 7c686c7, but if there's a better way let me know.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the note is reasonable enough for now. We are working on versioning things better in this repository, but we can go with this until then.

-------------------------------

.. note::

The logging directory can only be configured starting in Galactic.

The logging directory can be configured through two environment variables: ``ROS_LOG_DIR`` and ``ROS_HOME``.
The logic is as follows:

* Use ``$ROS_LOG_DIR`` if ``ROS_LOG_DIR`` is set and not empty.
* Otherwise, use ``$ROS_HOME/log``, using ``~/.ros`` for ``ROS_HOME`` if not set or if empty.

For example, to set the logging directory to ``~/my_logs``:

.. tabs::

.. group-tab:: Linux

.. code-block:: bash

export ROS_LOG_DIR=~/my_logs
ros2 run logging_demo logging_demo_main

.. group-tab:: macOS

.. code-block:: bash

export ROS_LOG_DIR=~/my_logs
ros2 run logging_demo logging_demo_main

.. group-tab:: Windows

.. code-block:: bash

set "ROS_LOG_DIR=~/my_logs"
ros2 run logging_demo logging_demo_main

You will then find the logs under ``~/my_logs/``.

Alternatively, you can set ``ROS_HOME`` and the logging directory will be relative to it (``$ROS_HOME/log``).
``ROS_HOME`` is intended to be used by anything that needs a base directory.
Note that ``ROS_LOG_DIR`` has to be either unset or empty.
For example, with ``ROS_HOME`` set to ``~/my_ros_home``:

.. tabs::

.. group-tab:: Linux

.. code-block:: bash

export ROS_HOME=~/my_ros_home
ros2 run logging_demo logging_demo_main

.. group-tab:: macOS

.. code-block:: bash

export ROS_HOME=~/my_ros_home
ros2 run logging_demo logging_demo_main

.. group-tab:: Windows

.. code-block:: bash

set "ROS_HOME=~/my_ros_home"
ros2 run logging_demo logging_demo_main

You will then find the logs under ``~/my_ros_home/log/``.

Logger level configuration: programmatically
--------------------------------------------

Expand Down