[logback-dev] [JIRA] (LOGBACK-1477) LoggerContext.putProperty("application-name", "applicationName"); Application name policy implementation, invalid after logback.xml change

QOS.CH (JIRA) noreply-jira at qos.ch
Fri Jul 26 11:07:00 CEST 2019


zhang created LOGBACK-1477:
------------------------------

             Summary: LoggerContext.putProperty("application-name",  "applicationName");Application name policy implementation, invalid after logback.xml change
                 Key: LOGBACK-1477
                 URL: https://jira.qos.ch/browse/LOGBACK-1477
             Project: logback
          Issue Type: Bug
    Affects Versions: 1.2.3
         Environment: package test;

import java.io.File;

import org.slf4j.ILoggerFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.classic.joran.JoranConfigurator;

public final class Test \{

    public final static Logger log = LoggerFactory.getLogger(Test.class);

    public static void main(String[] args) throws Exception \{

        log.error("ZZZZZZZZZZZZZZZZZZZZZZZZZ");

        ILoggerFactory loggerFactory = LoggerFactory.getILoggerFactory();
        LoggerContext lc = (LoggerContext) loggerFactory;
        JoranConfigurator configurator = new JoranConfigurator();
        configurator.setContext(lc);
        lc.reset();

        final File file = new File("./config/logback.xml");

        lc.putProperty({color:#ff0000}"application-name"{color},  "applicationName");

        configurator.doConfigure(file.getAbsolutePath());

        while (true) \{

            log.info("YY");

            Thread.sleep(5000);
            System.err.println("X");

        }

    }

}

 

<?xml version="1.0" encoding="UTF-8"?>
<configuration debug="false" scan="true" nolog="true" scanPeriod="60 seconds">

    <property name="logging_home" value="logs/{color:#ff0000}$\{application-name}{color}" />
    <property name="logging_backup_home" value="$\{logging_home}/backup" />

    <appender name="fileInfoLog" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>$\{logging_home}/logging-info.log</file>
        <filter class="ch.qos.logback.classic.filter.LevelFilter">
            <level>ERROR</level>
            <onMatch>DENY</onMatch>
            <onMismatch>ACCEPT</onMismatch>
        </filter>
        <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
            <FileNamePattern>
                $\{logging_backup_home}/%d\{yyyy-MM-dd}/logging-info.%d\{yyyyMMdd}.%i.log.zip
            </FileNamePattern>
            <maxHistory>30</maxHistory>
            <maxFileSize>128MB</maxFileSize>
        </rollingPolicy>

        <layout class="ch.qos.logback.classic.PatternLayout">
            <pattern>
                %d\{yyyy-MM-dd HH:mm:ss.SSS} [%thread] [%-5level] [%logger:%line] - %msg%n
            </pattern>
        </layout>
    </appender>

    <root level="DEBUG">
        <appender-ref ref="fileInfoLog" />
    </root>

</configuration>

 
            Reporter: zhang
            Assignee: Logback dev list
         Attachments: logback.xml, Test.java, XXXXXXXXXXX.png

The application starts the specified name or process name, ouput loggings to directory->applicationName,then adjusts the logback.xml level="DEBUG" to level="INFO"  during the running process, the application name policy implementation is invalid, the loggings output change to directory->application-name_IS_UNDEFINED.



--
This message was sent by Atlassian JIRA
(v7.3.1#73012)


More information about the logback-dev mailing list