Log4j2的properties详解

引言

官方配置文档:https://logging.apache.org/log4j/2.x/manual/filters.html


:Property Substitution

个人理解就是定义的xml里的全局常量,一处定义多处使用。

Log4j 2 supports the ability to specify tokens in the configuration as references to properties defined elsewhere. In a manner similar to Maven, this allows variables declared as ${name} to be resolved using properties declared in the configuration itself.

    <properties>
        <property name="LOG_HOME">./logsproperty>
        <Property name="FILE_NAME" value="practisesvr"/>
        <Property name="LOG_PATTERN" value="[%d{yyyy-MM-dd HH:mm:ss}] [%-5level] [%thread] [%file:%line] → [%enc{%m}{CRLF}]%n"/>
    properties>

    <appenders>
        <console name="CONSOLE" target="SYSTEM_OUT">
            <PatternLayout pattern="${LOG_PATTERN}"/>
        console>
    appenders>

你可能感兴趣的:(日志,log4j,java,apache)