[logback-user] Dynamic loggers?

Chris shef31 at yahoo.com
Wed Sep 22 20:48:37 CEST 2010


My app needs to create log files on the fly and put them in their own 
directories. For example, suppose a user creates a new entity in our 
system named "foo". We want to create a new subdirectory, /logs/foo, and 
put foo-related events there. When the user is done with foo, we need to 
close the logger and release resources.

How can I do this with logback?

The difficulty is that we can't know in advance the name of the logger 
or the filename it needs to use, so we can't configure it in logback.xml.


Also, it doesn't look like Logger has a close() method, so even if I 
write a custom Appender, I don't know how I'd notify it to shut down. 
I'd prefer to use generic slf4j in the application itself.





More information about the Logback-user mailing list