Is there a way to programmatically configure logback without using any config file at all.
and that is still configuring using a config file.
Use-case: multiple invocations of same app (with same classpath) needs to
log to different file appenders, possibly with different patterns.
Hence, need facility to dynamically configure these at runtime (at startup).
In log4j, I can do this using
Logger logger = Logger.getLogger("abc.xyz");
FileAppender fileAppender = (FileAppender)logger.getAppender("file");
if(fileAppender != null) {
fileAppender.setFile("new.log");
fileAppender.setLayout(new PatternLayout("%d{ISO8601} %5p %t [%c:%L] %m%n"));
fileAppender.activateOptions();
}
How do I do similar thing in logback?
Thanks
Cheenu