How can I configure an Async Appender using a properties file in log4j2?

时间:2018-06-18 11:40:05

标签: log4j2 properties-file

I'd like to configure async appenders in log4j2, but Im also wanting to keep my configuration to simple properties.

 <?xml version="1.0" encoding="UTF-8"?>
<Configuration status="debug">
    <Appenders>
        <Console name="Console-Appender" target="SYSTEM_OUT">
            <PatternLayout>
                <pattern>
                    [%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %c{1} - %msg%n
                </pattern>>
            </PatternLayout>
        </Console>
        <RollingRandomAccessFile name="Rolling-Random-Access-File-Appender"
                                 fileName="logs/rollingrandomaccessfile.log"
                                 filePattern="archive/logs/rollingrandomaccessfile.log.%d{yyyy-MM-dd-hh-mm}.gz">
            <PatternLayout pattern="[%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %c{1} - %msg%n"/>
            <Policies>
                <SizeBasedTriggeringPolicy size="1 KB"/>
            </Policies>
            <DefaultRolloverStrategy max="30"/>
        </RollingRandomAccessFile>

    </Appenders>
    <Loggers>
        <AsyncLogger  name="guru.springframework.blog.log4j2async" level="debug">
            <AppenderRef ref="Rolling-Random-Access-File-Appender"/>
        </AsyncLogger>
        <Root level="debug">
            <AppenderRef ref="Console-Appender"/>
        </Root>
    </Loggers>
</Configuration>

what would this look like in a property file?

0 个答案:

没有答案