2016-12-15 16:09:27 -07:00
|
|
|
.. _logging:
|
|
|
|
|
2013-08-07 23:44:34 +01:00
|
|
|
=======
|
|
|
|
Logging
|
|
|
|
=======
|
|
|
|
|
2022-10-24 10:06:40 -06:00
|
|
|
The Salt Project tries to get the logging to work for you and help us solve any
|
2013-08-07 23:44:34 +01:00
|
|
|
issues you might find along the way.
|
|
|
|
|
2014-12-10 19:37:16 -08:00
|
|
|
If you want to get some more information on the nitty-gritty of salt's logging
|
2016-12-15 16:09:27 -07:00
|
|
|
system, please head over to the :ref:`logging development
|
2018-05-31 15:25:53 -05:00
|
|
|
document <logging-internals>`, if all you're after is salt's logging
|
2013-08-30 19:33:22 +00:00
|
|
|
configurations, please continue reading.
|
|
|
|
|
2013-08-07 23:50:51 +01:00
|
|
|
|
2016-08-10 11:45:04 -06:00
|
|
|
.. conf_log:: log_levels
|
|
|
|
|
|
|
|
Log Levels
|
|
|
|
==========
|
|
|
|
|
|
|
|
The log levels are ordered numerically such that setting the log level to a
|
|
|
|
specific level will record all log statements at that level and higher. For
|
|
|
|
example, setting ``log_level: error`` will log statements at ``error``,
|
|
|
|
``critical``, and ``quiet`` levels, although nothing *should* be logged at
|
|
|
|
``quiet`` level.
|
|
|
|
|
|
|
|
Most of the logging levels are defined by default in Python's logging library
|
2018-05-31 15:25:53 -05:00
|
|
|
and can be found in the official :ref:`Python documentation <python:levels>`.
|
|
|
|
Salt uses some more levels in addition to the standard levels. All levels
|
|
|
|
available in salt are shown in the table below.
|
2016-08-10 11:45:04 -06:00
|
|
|
|
|
|
|
.. note::
|
|
|
|
|
|
|
|
Python dependencies used by salt may define and use additional logging
|
|
|
|
levels. For example, the Python 2 version of the ``multiprocessing``
|
|
|
|
standard Python library `uses the levels
|
2021-01-13 12:55:50 -06:00
|
|
|
<https://docs.python.org/3/library/multiprocessing.html#logging>`_
|
2016-08-10 11:45:04 -06:00
|
|
|
``subwarning``, 25 and ``subdebug``, 5.
|
|
|
|
|
2016-09-29 10:11:01 -06:00
|
|
|
+----------+---------------+--------------------------------------------------------------------------+
|
|
|
|
| Level | Numeric value | Description |
|
|
|
|
+==========+===============+==========================================================================+
|
|
|
|
| quiet | 1000 | Nothing should be logged at this level |
|
|
|
|
+----------+---------------+--------------------------------------------------------------------------+
|
|
|
|
| critical | 50 | Critical errors |
|
|
|
|
+----------+---------------+--------------------------------------------------------------------------+
|
|
|
|
| error | 40 | Errors |
|
|
|
|
+----------+---------------+--------------------------------------------------------------------------+
|
|
|
|
| warning | 30 | Warnings |
|
|
|
|
+----------+---------------+--------------------------------------------------------------------------+
|
|
|
|
| info | 20 | Normal log information |
|
|
|
|
+----------+---------------+--------------------------------------------------------------------------+
|
|
|
|
| profile | 15 | Profiling information on salt performance |
|
|
|
|
+----------+---------------+--------------------------------------------------------------------------+
|
|
|
|
| debug | 10 | Information useful for debugging both salt implementations and salt code |
|
|
|
|
+----------+---------------+--------------------------------------------------------------------------+
|
|
|
|
| trace | 5 | More detailed code debugging information |
|
|
|
|
+----------+---------------+--------------------------------------------------------------------------+
|
|
|
|
| garbage | 1 | Even more debugging information |
|
|
|
|
+----------+---------------+--------------------------------------------------------------------------+
|
|
|
|
| all | 0 | Everything |
|
|
|
|
+----------+---------------+--------------------------------------------------------------------------+
|
2016-08-10 11:45:04 -06:00
|
|
|
|
2013-08-07 23:50:51 +01:00
|
|
|
Available Configuration Settings
|
|
|
|
================================
|
|
|
|
|
2013-12-13 17:33:32 -07:00
|
|
|
.. conf_log:: log_file
|
2013-08-07 23:50:51 +01:00
|
|
|
|
|
|
|
``log_file``
|
|
|
|
------------
|
|
|
|
|
2016-08-10 10:46:39 -06:00
|
|
|
The log records can be sent to a regular file, local path name, or network
|
|
|
|
location. Remote logging works best when configured to use rsyslogd(8) (e.g.:
|
|
|
|
``file:///dev/log``), with rsyslogd(8) configured for network logging. The
|
|
|
|
format for remote addresses is:
|
2018-05-28 16:13:12 -05:00
|
|
|
|
|
|
|
.. code-block:: text
|
|
|
|
|
|
|
|
<file|udp|tcp>://<host|socketpath>:<port-if-required>/<log-facility>
|
|
|
|
|
|
|
|
Where ``log-facility`` is the symbolic name of a syslog facility as defined in
|
2018-05-31 15:25:53 -05:00
|
|
|
the :py:meth:`SysLogHandler documentation
|
2018-05-28 16:13:12 -05:00
|
|
|
<logging.handlers.SysLogHandler.encodePriority>`. It defaults to ``LOG_USER``.
|
2015-12-15 14:56:13 -05:00
|
|
|
|
2016-08-10 10:46:39 -06:00
|
|
|
Default: Dependent of the binary being executed, for example, for
|
|
|
|
``salt-master``, ``/var/log/salt/master``.
|
2015-12-15 14:56:13 -05:00
|
|
|
|
2013-08-07 23:50:51 +01:00
|
|
|
Examples:
|
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
log_file: /var/log/salt/master
|
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
log_file: /var/log/salt/minion
|
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
log_file: file:///dev/log
|
2016-09-29 10:11:01 -06:00
|
|
|
|
2015-12-15 14:56:13 -05:00
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
log_file: file:///dev/log/LOG_DAEMON
|
2013-08-07 23:50:51 +01:00
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
log_file: udp://loghost:10514
|
|
|
|
|
2013-12-13 17:33:32 -07:00
|
|
|
.. conf_log:: log_level
|
2013-08-07 23:50:51 +01:00
|
|
|
|
|
|
|
``log_level``
|
|
|
|
-------------
|
|
|
|
|
2016-06-21 09:31:59 -06:00
|
|
|
Default: ``warning``
|
2013-08-07 23:50:51 +01:00
|
|
|
|
2016-06-28 10:03:59 -06:00
|
|
|
The level of log record messages to send to the console. One of ``all``,
|
|
|
|
``garbage``, ``trace``, ``debug``, ``profile``, ``info``, ``warning``,
|
2013-08-07 23:50:51 +01:00
|
|
|
``error``, ``critical``, ``quiet``.
|
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
log_level: warning
|
|
|
|
|
2015-12-13 17:22:28 -03:00
|
|
|
.. note::
|
2016-08-10 10:47:07 -06:00
|
|
|
Add ``log_level: quiet`` in salt configuration file to completely disable
|
|
|
|
logging. In case of running salt in command line use ``--log-level=quiet``
|
2015-12-13 17:22:28 -03:00
|
|
|
instead.
|
2013-08-07 23:50:51 +01:00
|
|
|
|
2013-12-13 17:33:32 -07:00
|
|
|
.. conf_log:: log_level_logfile
|
2013-08-07 23:50:51 +01:00
|
|
|
|
|
|
|
``log_level_logfile``
|
|
|
|
---------------------
|
|
|
|
|
2015-09-18 13:59:45 -07:00
|
|
|
Default: ``info``
|
2013-08-07 23:50:51 +01:00
|
|
|
|
2016-06-28 10:03:59 -06:00
|
|
|
The level of messages to send to the log file. One of ``all``, ``garbage``,
|
|
|
|
``trace``, ``debug``, ``profile``, ``info``, ``warning``, ``error``,
|
|
|
|
``critical``, ``quiet``.
|
2013-08-07 23:50:51 +01:00
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
log_level_logfile: warning
|
|
|
|
|
2013-12-13 17:33:32 -07:00
|
|
|
.. conf_log:: log_datefmt
|
2013-08-07 23:50:51 +01:00
|
|
|
|
|
|
|
``log_datefmt``
|
|
|
|
---------------
|
|
|
|
|
|
|
|
Default: ``%H:%M:%S``
|
|
|
|
|
2014-12-10 19:37:16 -08:00
|
|
|
The date and time format used in console log messages. Allowed date/time
|
2018-05-28 16:13:12 -05:00
|
|
|
formatting matches those used in :py:func:`time.strftime`.
|
2013-08-07 23:50:51 +01:00
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
log_datefmt: '%H:%M:%S'
|
|
|
|
|
2013-12-13 17:33:32 -07:00
|
|
|
.. conf_log:: log_datefmt_logfile
|
2013-08-07 23:50:51 +01:00
|
|
|
|
|
|
|
``log_datefmt_logfile``
|
|
|
|
-----------------------
|
|
|
|
|
|
|
|
Default: ``%Y-%m-%d %H:%M:%S``
|
|
|
|
|
2014-12-10 19:37:16 -08:00
|
|
|
The date and time format used in log file messages. Allowed date/time
|
2018-05-28 16:13:12 -05:00
|
|
|
formatting matches those used in :py:func:`time.strftime`.
|
2013-08-07 23:50:51 +01:00
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
log_datefmt_logfile: '%Y-%m-%d %H:%M:%S'
|
|
|
|
|
2013-12-13 17:33:32 -07:00
|
|
|
.. conf_log:: log_fmt_console
|
2013-08-07 23:50:51 +01:00
|
|
|
|
|
|
|
``log_fmt_console``
|
|
|
|
-------------------
|
|
|
|
|
|
|
|
Default: ``[%(levelname)-8s] %(message)s``
|
|
|
|
|
2015-03-26 00:10:55 -06:00
|
|
|
The format of the console logging messages. All standard python logging
|
2018-05-28 16:13:12 -05:00
|
|
|
:py:class:`~logging.LogRecord` attributes can be used. Salt also provides these
|
|
|
|
custom LogRecord attributes to colorize console log output:
|
2015-03-26 00:10:55 -06:00
|
|
|
|
|
|
|
.. code-block:: python
|
|
|
|
|
|
|
|
"%(colorlevel)s" # log level name colorized by level
|
|
|
|
"%(colorname)s" # colorized module name
|
|
|
|
"%(colorprocess)s" # colorized process number
|
|
|
|
"%(colormsg)s" # log message colorized by level
|
|
|
|
|
|
|
|
.. note::
|
|
|
|
The ``%(colorlevel)s``, ``%(colorname)s``, and ``%(colorprocess)``
|
|
|
|
LogRecord attributes also include padding and enclosing brackets, ``[`` and
|
|
|
|
``]`` to match the default values of their collateral non-colorized
|
|
|
|
LogRecord attributes.
|
2013-08-07 23:50:51 +01:00
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
log_fmt_console: '[%(levelname)-8s] %(message)s'
|
|
|
|
|
2013-12-13 17:33:32 -07:00
|
|
|
.. conf_log:: log_fmt_logfile
|
2013-08-07 23:50:51 +01:00
|
|
|
|
|
|
|
``log_fmt_logfile``
|
|
|
|
-------------------
|
|
|
|
|
2016-06-02 17:38:31 +02:00
|
|
|
Default: ``%(asctime)s,%(msecs)03d [%(name)-17s][%(levelname)-8s] %(message)s``
|
2013-08-07 23:50:51 +01:00
|
|
|
|
2015-03-26 00:10:55 -06:00
|
|
|
The format of the log file logging messages. All standard python logging
|
2018-05-28 16:13:12 -05:00
|
|
|
:py:class:`~logging.LogRecord` attributes can be used. Salt also provides
|
|
|
|
these custom LogRecord attributes that include padding and enclosing brackets
|
|
|
|
``[`` and ``]``:
|
2015-03-26 00:10:55 -06:00
|
|
|
|
|
|
|
.. code-block:: python
|
|
|
|
|
|
|
|
"%(bracketlevel)s" # equivalent to [%(levelname)-8s]
|
|
|
|
"%(bracketname)s" # equivalent to [%(name)-17s]
|
|
|
|
"%(bracketprocess)s" # equivalent to [%(process)5s]
|
2013-08-07 23:50:51 +01:00
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
2016-06-02 17:38:31 +02:00
|
|
|
log_fmt_logfile: '%(asctime)s,%(msecs)03d [%(name)-17s][%(levelname)-8s] %(message)s'
|
2013-08-07 23:50:51 +01:00
|
|
|
|
2013-12-13 17:33:32 -07:00
|
|
|
.. conf_log:: log_granular_levels
|
2013-08-07 23:50:51 +01:00
|
|
|
|
|
|
|
``log_granular_levels``
|
|
|
|
-----------------------
|
|
|
|
|
|
|
|
Default: ``{}``
|
|
|
|
|
2017-11-08 16:11:46 -08:00
|
|
|
This can be used to control logging levels more specifically, based on log call name. The example sets
|
|
|
|
the main salt library at the 'warning' level, sets ``salt.modules`` to log
|
|
|
|
at the ``debug`` level, and sets a custom module to the ``all`` level:
|
2013-08-07 23:50:51 +01:00
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
log_granular_levels:
|
2015-01-22 17:34:49 -08:00
|
|
|
'salt': 'warning'
|
2013-08-07 23:50:51 +01:00
|
|
|
'salt.modules': 'debug'
|
2017-11-08 16:11:46 -08:00
|
|
|
'salt.loader.saltmaster.ext.module.custom_module': 'all'
|
2013-08-30 23:14:40 +01:00
|
|
|
|
2018-07-20 09:35:23 -07:00
|
|
|
.. conf_log:: log_fmt_jid
|
2018-07-18 13:47:53 -07:00
|
|
|
|
2023-02-06 19:32:11 +00:00
|
|
|
You can determine what log call name to use here by adding ``%(module)s`` to the
|
|
|
|
log format. Typically, it is the path of the file which generates the log
|
2022-10-24 13:34:22 -05:00
|
|
|
without the trailing ``.py`` and with path separators replaced with ``.``
|
2022-10-24 10:06:40 -06:00
|
|
|
|
|
|
|
|
2018-07-18 13:47:53 -07:00
|
|
|
``log_fmt_jid``
|
|
|
|
-------------------
|
|
|
|
|
|
|
|
Default: ``[JID: %(jid)s]``
|
|
|
|
|
|
|
|
The format of the JID when added to logging messages.
|
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
log_fmt_jid: '[JID: %(jid)s]'
|
|
|
|
|
2013-08-30 23:14:40 +01:00
|
|
|
External Logging Handlers
|
|
|
|
-------------------------
|
|
|
|
|
|
|
|
Besides the internal logging handlers used by salt, there are some external
|
2016-12-15 16:09:27 -07:00
|
|
|
which can be used, see the :ref:`external logging handlers<external-logging-handlers>`
|
2013-08-30 23:14:40 +01:00
|
|
|
document.
|