[logback-user] Logback FileAppender question: is it able to create log filenames dynamically by a string passed e.g. in LOGGER.trace()?

Thomas Schittli Thomas.Schittli at jig.ch
Tue Aug 30 14:59:56 CEST 2022

Good afternoon

The documentation for SLF4J and Logback is very detailed 😊, but unfortunately it is still difficult to understand the various possibilities and mechanisms, so I have a question:

Is it possible to configure the logback FileAppender
so that it automatically / dynamically creates logfile names based on a string which the developer passes in e.g. LOGGER.trace()?

The background to the idea is as follows:

  1.  The developer is programming a new module (e.g. a configuration manager)
and he would like to have the log entries summarised in a separate log file.

  2.  Therefore, he calls something like that: LOGGER.trace(“Config-Mgr”, “Message”)

  3.  SLF4J / Logback automatically reads this string and create this Logfile: AppLog-Config-Mgr.log

  4.  The central element is that we do not have to modify logback.xml and create an appender for each Logfile.

This means that if the user now calls e.g.: LOGGER.trace(“User-Actionlog”, “Message”)
then this new log file will created without having to modify logback.xml:

Thank you very much for any tips & tricks 😊

Thanks a lot, kind regards,

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.qos.ch/pipermail/logback-user/attachments/20220830/4df874c5/attachment.html>

More information about the logback-user mailing list