Hello,

It seems to be possible to read the pattern of an appender out of the logback.xml-file. But I don't know how exactly. We use the followin Code to get the the filepath form the appender (found somwhere in this mailinglist):
        String path = "";

LoggerContext ctx = (LoggerContext)LoggerFactory.getILoggerFactory();


        for (Logger l : ctx.getLoggerList()) {
ch.qos.logback.classic.Logger log =(ch.qos.logback.classic.Logger) l; Iterator<Appender<ILoggingEvent>> it = log.iteratorForAppenders();

            while (it.hasNext()) {
                Appender<ILoggingEvent> ap = it.next();

if (ap instanceof FileAppender<?> || ap instanceof RollingFileAppender<?>) {
                    FileAppender<?> fileAppender = (FileAppender<?>)ap;
                    path = fileAppender.getFile();
                }
            }
        }
        return path;
    }

Is it possible to implement a method which also gets the pattern of the appender out of the file? I tried different ways but somehow I don't get it.

Thanks in advance!

Regards,

Noah
_______________________________________________
Logback-user mailing list
[email protected]
http://qos.ch/mailman/listinfo/logback-user

Reply via email to