use of ch.qos.logback.classic.layout.TTLLLayout 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);
}
}
use of ch.qos.logback.classic.layout.TTLLLayout in project grakn by graknlabs.
the class CoreLogback method configure.
public void configure(LoggerContext logContext, CoreConfig.Log logConfig) {
// all appenders use the same layout
LayoutWrappingEncoder<ILoggingEvent> encoder = new LayoutWrappingEncoder<>();
encoder.setContext(logContext);
// "%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n"
TTLLLayout layout = new TTLLLayout();
layout.setContext(logContext);
layout.start();
encoder.setLayout(layout);
Map<String, Appender<ILoggingEvent>> appenders = new HashMap<>();
logConfig.output().outputs().forEach((name, outputType) -> appenders.put(name, appender(name, logContext, encoder, layout, outputType)));
configureRootLogger(logConfig.logger().defaultLogger(), logContext, appenders);
logConfig.logger().filteredLoggers().values().forEach(l -> configureLogger(l, logContext, appenders));
}
Aggregations