Search in sources :

Example 1 with HTMLLayout

use of ch.qos.logback.classic.html.HTMLLayout in project uavstack by uavorg.

the class LogBackHookProxy method figureoutLogConfiguration.

private void figureoutLogConfiguration(Logger Logger, LinkedList<LogProfileInfo> list, String appid) {
    Iterator<Appender<ILoggingEvent>> appenders = Logger.iteratorForAppenders();
    while (appenders != null && appenders.hasNext()) {
        LogProfileInfo logProfileInfo = new LogProfileInfo();
        if (appid != null) {
            logProfileInfo.setAppId(appid);
        }
        logProfileInfo.setLogType(LogProfileInfo.LogType.Log4j);
        Map<String, String> attributes = new HashMap<String, String>();
        attributes.put(LogProfileInfo.ENGINE, "logback");
        Appender<ILoggingEvent> appender = appenders.next();
        if (!(appender instanceof FileAppender<?>)) {
            continue;
        }
        FileAppender<ILoggingEvent> fileAppender = (FileAppender<ILoggingEvent>) appender;
        @SuppressWarnings("rawtypes") LayoutWrappingEncoder encoder = (LayoutWrappingEncoder) fileAppender.getEncoder();
        Layout<?> layout = encoder.getLayout();
        if (null != layout) {
            if (layout instanceof PatternLayout) {
                PatternLayout patternLayout = (PatternLayout) encoder.getLayout();
                attributes.put(LogProfileInfo.PATTERN, patternLayout.getPattern());
            } else if (layout instanceof HTMLLayout) {
                attributes.put(LogProfileInfo.PATTERN, "HTMLLayout");
            } else if (layout instanceof XMLLayout) {
                attributes.put(LogProfileInfo.PATTERN, "XMLLayout");
            } else if (layout instanceof TTLLLayout) {
                attributes.put(LogProfileInfo.PATTERN, "TTCCLayout");
            }
        }
        logProfileInfo.setFilePath(fileAppender.getFile());
        logProfileInfo.setAttributes(attributes);
        list.add(logProfileInfo);
    }
}
Also used : FileAppender(ch.qos.logback.core.FileAppender) Appender(ch.qos.logback.core.Appender) FileAppender(ch.qos.logback.core.FileAppender) HashMap(java.util.HashMap) HTMLLayout(ch.qos.logback.classic.html.HTMLLayout) PatternLayout(ch.qos.logback.classic.PatternLayout) TTLLLayout(ch.qos.logback.classic.layout.TTLLLayout) ILoggingEvent(ch.qos.logback.classic.spi.ILoggingEvent) LogProfileInfo(com.creditease.uav.profiling.handlers.log.LogProfileInfo) XMLLayout(ch.qos.logback.classic.log4j.XMLLayout) LayoutWrappingEncoder(ch.qos.logback.core.encoder.LayoutWrappingEncoder)

Aggregations

PatternLayout (ch.qos.logback.classic.PatternLayout)1 HTMLLayout (ch.qos.logback.classic.html.HTMLLayout)1 TTLLLayout (ch.qos.logback.classic.layout.TTLLLayout)1 XMLLayout (ch.qos.logback.classic.log4j.XMLLayout)1 ILoggingEvent (ch.qos.logback.classic.spi.ILoggingEvent)1 Appender (ch.qos.logback.core.Appender)1 FileAppender (ch.qos.logback.core.FileAppender)1 LayoutWrappingEncoder (ch.qos.logback.core.encoder.LayoutWrappingEncoder)1 LogProfileInfo (com.creditease.uav.profiling.handlers.log.LogProfileInfo)1 HashMap (java.util.HashMap)1