use of ch.qos.logback.classic.PatternLayout in project jadx by skylot.
the class LogCollector method register.
public static void register() {
Logger rootLogger = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
LoggerContext loggerContext = rootLogger.getLoggerContext();
PatternLayout layout = new PatternLayout();
layout.setContext(loggerContext);
layout.setPattern("%-5level: %msg%n");
layout.start();
instance.setContext(loggerContext);
instance.setLayout(layout);
instance.start();
rootLogger.addAppender(instance);
}
use of ch.qos.logback.classic.PatternLayout in project jackrabbit-oak by apache.
the class LogDumper method getLogs.
private String getLogs() {
if (appender == null) {
return "<Logs cannot be determined>";
}
PatternLayout layout = createLayout();
StringBuilder sb = new StringBuilder();
for (int i = 0; i < appender.getLength(); i++) {
sb.append(layout.doLayout(appender.get(i)));
}
return sb.toString();
}
use of ch.qos.logback.classic.PatternLayout in project sling by apache.
the class LogConfig method createLayout.
public PatternLayout createLayout() {
// The java.util.MessageFormat pattern to use for formatting log
// messages with the root logger.
// This is a java.util.MessageFormat pattern supporting up to six
// arguments:
// {0} The timestamp of type java.util.Date,
// {1} the log marker,
// {2} the name of the current thread,
// {3} the name of the logger,
// {4} the debug level and
// {5} the actual debug message
Pattern date = Pattern.compile("\\{0,date,(.+?)\\}");
Matcher m = date.matcher(pattern);
String logBackPattern = pattern;
if (m.matches()) {
// If legacy pattern then transform the date format
logBackPattern = m.replaceAll("%d'{'$1'}'");
}
boolean legacyPattern = false;
for (String marker : LEGACY_MARKERS) {
if (logBackPattern.contains(marker)) {
legacyPattern = true;
break;
}
}
if (legacyPattern) {
// [%thread] %logger %msg%n
try {
logBackPattern = MessageFormat.format(logBackPattern, "zero", "%marker", "%thread", "%logger", "%level", "%message") + "%n";
} catch (IllegalArgumentException e) {
log.warn("Invalid message format provided [{}]. Would use the default pattern", logBackPattern, e);
logBackPattern = LogConfigManager.LOG_PATTERN_DEFAULT;
}
}
PatternLayout pl = new PatternLayout();
pl.setPattern(logBackPattern);
pl.setOutputPatternAsHeader(false);
pl.setContext(loggerContext);
pl.start();
return pl;
}
use of ch.qos.logback.classic.PatternLayout in project sling by apache.
the class TestLogServlet method createLayout.
private void createLayout(Map<String, ?> config) {
String pattern = PropertiesUtil.toString(config.get(PROP_MSG_PATTERN), DEFAULT_PATTERN);
PatternLayout pl = new PatternLayout();
pl.setPattern(pattern);
pl.setOutputPatternAsHeader(false);
pl.setContext(getContext());
pl.start();
layout = pl;
}
use of ch.qos.logback.classic.PatternLayout in project MantaroBot by Mantaro.
the class DiscordLogBack method start.
@Override
public void start() {
patternLayout = new PatternLayout();
patternLayout.setContext(getContext());
patternLayout.setPattern("[`%d{HH:mm:ss}`] [`%t/%level`] [`%logger{0}`]: %msg");
patternLayout.start();
super.start();
}
Aggregations