Is loglevels/* still working?

I’ve been trying to lower the log levels for Mopidy to INFO so that I can reduce the noise and debug an extension that I am working on.

I can’t figure out how to make it work. My mopidy.conf contains:

[logging]
color = true
console_format = %(levelname)-8s %(message)s
debug_format = %(levelname)-8s %(asctime)s [%(process)d:%(threadName)s] %(name)s\n  %(message)s
debug_file = mopidy.log
config_file = /Users/jcass/.config/mopidy/logging.conf

[loglevels]
root = INFO
mopidy = INFO
mopidy_pandora.backend = DEBUG

…but it doesn’t have any effect and whatever is specified in logging.conf (either higher or lower than the level I am looking for) will take precedence and end up in mopidy.log.

Is anybody using this at the moment and are the fixes mentioned in https://github.com/mopidy/mopidy/issues/684 still effective?

Update: it does seem to reduce the log levels specified in logging.conf, but only for messages displayed to the console if mopidy is started from the terminal.

When run as a service mopidy.log still contains everything - is there perhaps another logging endpoint used for the log file that should be configured as well?

Looking at the code it seems that the verbosity filter is only applied to the StreamHandler in mopidy.internal.log.setup_console_logging.

If we want to align what is logged to the console with what is logged to mopidy.log (and make the loglevels/* parameter effective for service users), then we would have to add VerbosityFilter to the FileHandler that is defined in logging.conf- any objections to this idea?

The logging features have grown somewhat organically, so I’m not at all surprised that not all features works as orthonogally as they should.

Today, there’s four ways of logging that I can think of:

  1. to the console (run mopidy),
  2. to the console and then into some logging service (run mopidy with systemd, and the console log ends up in the systemd journal),
  3. to a debug log (run mopidy --save-debug-log), typically ./mopidy.log,
  4. to anything defined in a logging config, as pointed to by the config value logging/config_file, typically /var/log/mopidy/mopidy.log.

I believe loglevels/* works for cases 1 and 2, but not 3 or 4. Am I right?

One possible solution is to throw away the --save-debug-log option and replace it with mopidy -vvvv > mopidy.log or even mopidy -vvvv | tee mopidy.log in the troubleshooting docs, and stop shipping a logging.conf with the Debian package, as modern systems now run systemd and journald, so we shouldn’t need to take care of file logging ourselves. That way we only have the logging to stdout left, and the question is just in what format (e.g. logging/console_format or logging/debug_format), at what general verbosity level (e.g. -vvvv), and with what specific filters (as defined by loglevels/*).

Yes loglevels/* only works for cases 1 and 2 as far as I can tell.

I’m not that familiar with systemd logging in Debian so can’t comment on which approach would be best, though what you are proposing sounds like it will consolidate things a lot and make it easier to maintain.

I’ve summarized the current state and proposed a set of changes in https://github.com/mopidy/mopidy/issues/1452