Is it possible to configure logback logger levels on the command line?

Yes, seems there is no such feature. As I understand, it is partly because that logback configuration is more complex so quite difficult to achieve reasonable configuration flexibility by flat string properties.
Partly because, imho, it encourages bad practice – placing too many system properties – leads to bloated run-scripts or command lines, more difficult to manage than separate logging configuration files.

However, I could suggest several options:

  • use ${sys.prop.var.name} substitutions in your logback.xml config file
  • copy logback.xml locally, modify it with desired logger levels and specify -Dlogback.configurationFile=/path/to/customised/logback.xml. Keep in mind that “Logback-classic can scan for changes in its configuration file and automatically reconfigure itself when the configuration file changes”. So, you even don’t need to relaunch your process to change logging levels.
  • DIY: Add a code in your application which would read system properties and apply the properties to the logging levels during start up.

Leave a Comment