Search in sources :

Example 1 with SiftingAppender

use of ch.qos.logback.classic.sift.SiftingAppender in project qpid-broker-j by apache.

the class QpidBrokerTestCase method getFileFromSiftingAppender.

private File getFileFromSiftingAppender(final ch.qos.logback.classic.Logger logger) {
    String key = logger.getLoggerContext().getProperty(LogbackPropertyValueDiscriminator.CLASS_QUALIFIED_TEST_NAME);
    for (Iterator<Appender<ILoggingEvent>> index = logger.iteratorForAppenders(); index.hasNext(); ) /* do nothing */
    {
        Appender<ILoggingEvent> appender = index.next();
        if (appender instanceof SiftingAppender) {
            SiftingAppender siftingAppender = (SiftingAppender) appender;
            Appender subAppender = siftingAppender.getAppenderTracker().find(key);
            if (subAppender instanceof FileAppender) {
                return new File(((FileAppender) subAppender).getFile());
            }
        }
    }
    return null;
}
Also used : FileAppender(ch.qos.logback.core.FileAppender) Appender(ch.qos.logback.core.Appender) SiftingAppender(ch.qos.logback.classic.sift.SiftingAppender) FileAppender(ch.qos.logback.core.FileAppender) ILoggingEvent(ch.qos.logback.classic.spi.ILoggingEvent) File(java.io.File) SiftingAppender(ch.qos.logback.classic.sift.SiftingAppender)

Aggregations

SiftingAppender (ch.qos.logback.classic.sift.SiftingAppender)1 ILoggingEvent (ch.qos.logback.classic.spi.ILoggingEvent)1 Appender (ch.qos.logback.core.Appender)1 FileAppender (ch.qos.logback.core.FileAppender)1 File (java.io.File)1