public PatternLayout createLayout()

in src/main/java/org/apache/sling/commons/log/logback/internal/LogConfig.java [107:160]


    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) {
            // Default {0,date,dd.MM.yyyy HH:mm:ss.SSS} *{4}* [{2}] {3} {5}
            // Convert patterns to %d{dd.MM.yyyy HH:mm:ss.SSS} *%level*
            // [%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;
            }
        }

        final PatternLayout pl = new PatternLayout();
        pl.setPattern(logBackPattern);
        pl.setOutputPatternAsHeader(false);
        pl.setContext(loggerContext);
        MaskingMessageUtil.setMessageConverter(pl);

        if (postProcessor != null) {
            pl.setPostCompileProcessor(postProcessor);
        }

        pl.start();
        return pl;
    }