mediamtx/docs/2-usage/17-logging.md
Alessandro Ros 3692b2448a
Some checks are pending
code_lint / go (push) Waiting to run
code_lint / go_mod (push) Waiting to run
code_lint / docs (push) Waiting to run
code_lint / api_docs (push) Waiting to run
code_test / test_64 (push) Waiting to run
code_test / test_32 (push) Waiting to run
code_test / test_e2e (push) Waiting to run
set syslog priority and do not write level and date to syslog (#4923) (#5296)
When writing log entries to syslog, pass the level (WARN, INFO, etc)
directly to syslog. Avoid writing level and date. This provides a
better integration and allows to use syslog search tools.
2025-12-27 14:06:26 +01:00

1.7 KiB

Logging

Log verbosity

Log verbosity can be set with the logLevel parameter:

# Verbosity of the program; available values are "error", "warn", "info", "debug".
logLevel: info

Log destinations

Log entries can be sent to multiple destinations. By default, they are printed on the console (stdout).

It is possible to write logs to a file by using these parameters:

# Destinations of log messages; available values are "stdout", "file" and "syslog".
logDestinations: [file]
# If "file" is in logDestinations, this is the file which will receive the logs.
logFile: mediamtx.log

It is possible to write logs to the system logging server (syslog) by using these parameters:

# Destinations of log messages; available values are "stdout", "file" and "syslog".
logDestinations: [syslog]
# If "syslog" is in logDestinations, use prefix for logs.
sysLogPrefix: mediamtx

Log entries can be queried by using:

journalctl SYSLOG_IDENTIFIER=mediamtx

If MediaMTX is also running as a system service, log entries can be queried by using:

journalctl -u mediamtx

Log file rotation

The log file can be periodically rotated or truncated by using an external utility.

On most Linux distributions, the logrotate utility is in charge of managing log files. It can be configured to handle the MediaMTX log file too by creating a configuration file, placed in /etc/logrotate.d/mediamtx, with this content:

/my/mediamtx/path/mediamtx.log {
    daily
    copytruncate
    rotate 7
    compress
    delaycompress
    missingok
    notifempty
}

This file will rotate the log file every day, adding a .NUMBER suffix to older copies:

mediamtx.log.1
mediamtx.log.2
mediamtx.log.3
...