Search in sources :

Example 1 with LogbackHelper

use of org.sonar.process.logging.LogbackHelper in project sonarqube by SonarSource.

the class TomcatAccessLog method configureLogbackAccess.

private static void configureLogbackAccess(Tomcat tomcat, Props props) {
    if (props.valueAsBoolean(PROPERTY_ENABLE, true)) {
        ProgrammaticLogbackValve valve = new ProgrammaticLogbackValve();
        LogbackHelper helper = new LogbackHelper();
        LogbackHelper.RollingPolicy policy = helper.createRollingPolicy(valve, props, "access");
        FileAppender appender = policy.createAppender("ACCESS_LOG");
        PatternLayoutEncoder fileEncoder = new PatternLayoutEncoder();
        fileEncoder.setContext(valve);
        fileEncoder.setPattern(props.value(PROPERTY_PATTERN, DEFAULT_SQ_ACCESS_LOG_PATTERN));
        fileEncoder.start();
        appender.setEncoder(fileEncoder);
        appender.start();
        valve.addAppender(appender);
        tomcat.getHost().getPipeline().addValve(valve);
    }
}
Also used : FileAppender(ch.qos.logback.core.FileAppender) PatternLayoutEncoder(ch.qos.logback.access.PatternLayoutEncoder) LogbackHelper(org.sonar.process.logging.LogbackHelper)

Aggregations

PatternLayoutEncoder (ch.qos.logback.access.PatternLayoutEncoder)1 FileAppender (ch.qos.logback.core.FileAppender)1 LogbackHelper (org.sonar.process.logging.LogbackHelper)1