Today, there are four logging output modes that I can think of:
Log to stdout (run mopidy),
Log to stdout and then into some logging service (start mopidy with systemd, and the stdout output ends up in the systemd journal),
Log to a debug log (run mopidy --save-debug-log), typically ./mopidy.log,
Log to anything defined in a logging config, as pointed to by the config value logging/config_file, typically /var/log/mopidy/mopidy.log.
The loglevels config section affects logging in cases 1 and 2, but not 3 or 4.
There are six global verbosity levels:
-q: warnings from mopidy, errors from everything else
default: info from mopidy, errors from everything else
-v: debug from mopidy, warnings from everything else
-vv: debug from mopidy, info from everything else
-vvv: debug from everything
-vvvv: no filter at all, even custom levels lower than debug will be included
The global verbosity level cannot be controlled from the config file.
We have two configs for logging format:
logging/console_format is used when no filter (verbosity level and loglevels/*) is at debug level (in other words: -q and default verbosity level, when no loglevels/* config is set to debug level). This is a conventional log format, just containing log level and message.
logging/debug_format is used when any filter (verbosity level and loglevels/*) is at debug level. This use multiple lines per log statement for better readability, and includes log level, time, PID, thread name, logger name, and message.
In addition the Debian package configures a log format for /var/log/mopidy/mopidy.log which has the same elements as logging/debug_format, just without newlines and with two items reordered.
Remove the --save-debug-log command line option and the logging/debug_file config value. Replace it with mopidy -vvvv | tee mopidy.log in the troubleshooting docs.
Stop shipping a logging.conf with the Debian and Arch packages, as modern systems now run systemd and journald, so we shouldn't need to take care of file logging ourselves.
Add examples to troubleshooting docs on how to access your Mopidy log using sudo journalctl -u mopidy, etc.
loglevels config section: Output mode 3 and 4 from the current situation is gone, so this now applies to all output modes.
Add a logging/verbosity config which is a number between -1 and 4 (-q and -vvvv), defaulting to 0, for controlling default logging verbosity level. Any use of -q or -v will override this, like any command line options always do.
Rename logging/debug_format to logging/format, keeping the current default log format.
Make distribution packages override logging/format in /etc/mopidy/mopidy.conf to not include timestamp and PID, as that is redundant in the systemd journal.
Test how journalctl behaves when getting multiline log messages. We have multiline log messages both because of the log format and because some log messages contains newlines, like MPD protocol messages.
Make distribution packages set logging/color to false, as I've seen the systemd journal print the color codes, so it becomes plain noise.
All logging goes to stdout, any redirection to syslog or file must be handled outside Mopidy.
We still have six global verbosity levels, but they can be set from config.
We no longer have a variance in logging format. A single config controls it all.
The loglevels/* config section affects all log output, making debugging something without knowing the internals of mopidy.internal.logging possible.
The text was updated successfully, but these errors were encountered: