Untitled

mail@pastecode.io avatar
unknown
plain_text
3 years ago
2.4 kB
20
Indexable
Never
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="DEBUG">
<Appenders>
    <Console name="LogToConsole" target="SYSTEM_OUT">
        <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
    </Console>
    <File name="LogToFile" fileName="logs/app.log">
        <PatternLayout>
            <Pattern>%d %p %c{1.} [%t] %m%n</Pattern>
        </PatternLayout>
    </File>
    <!-- file appender -->
    <RollingFile name="commons-log" fileName="logs/commons.log"
                 filePattern="logs/commons-%d{yyyy-MM-dd}.log">
        <!-- log pattern -->
        <PatternLayout>
            <pattern>[%-5level] %d{yyyy-MM-dd HH:mm:ss} %c{1} - %msg%n</pattern>
        </PatternLayout>

        <!-- set file size policy -->
        <Policies>
            <TimeBasedTriggeringPolicy />
            <SizeBasedTriggeringPolicy size="5 MB" />
        </Policies>
    </RollingFile>
    <RollingFile name="analytics-log" fileName="logs/analytics.log"
                 filePattern="logs/analytics-%d{yyyy-MM-dd}.log">
        <PatternLayout>
            <pattern>[%-5level] %d{yyyy-MM-dd HH:mm:ss} %c{1} - %msg%n</pattern>
        </PatternLayout>
        <Policies>
            <TimeBasedTriggeringPolicy interval="1" modulate="true"/>
        </Policies>
    </RollingFile>
</Appenders>
<Loggers>
    <Logger name="com.hatqptit.onlineshopping" level="debug" additivity="false">
        <AppenderRef ref="LogToFile"/>
        <AppenderRef ref="LogToConsole"/>
    </Logger>
    <Logger name="commons-log" level="debug" additivity="false">
        <appender-ref ref="commons-log" level="debug"/>>
    </Logger>
    <Logger name="analytics-log" level="debug" additivity="false">
        <appender-ref ref="analytics-log" level="debug"/>
    </Logger>
    <Logger name="org.springframework.boot" level="error" additivity="false">
        <AppenderRef ref="LogToConsole"/>
    </Logger>
    <Root level="error">
        <AppenderRef ref="LogToFile"/>
        <AppenderRef ref="LogToConsole"/>
    </Root>
</Loggers>
</Configuration>

    private static final Logger logCommons = LogManager.getLogger("commons-log");

    private static final Logger logAnalytics = LogManager.getLogger("analytics-log");

        logCommons.info ("Need it save into commons.log file");
        logAnalytics.info ("Only save into analytics.log file");