<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="INFO">
    <Properties>
        <Property name="LOG_DIR">logs</Property>
    </Properties>
    <Appenders>
        <Console name="ConsoleAppender" target="SYSTEM_OUT">
            <Filters>
                <MarkerFilter marker="LOG4JDBC_SQL" onMatch="ACCEPT" onMismatch="NEUTRAL"/>
                <MarkerFilter marker="LOG4JDBC_EXCEPTION" onMatch="ACCEPT" onMismatch="NEUTRAL"/>
                <MarkerFilter marker="LOG4JDBC_RESULTSETTABLE" onMatch="ACCEPT" onMismatch="NEUTRAL"/>
                <MarkerFilter marker="LOG4JDBC_NON_STATEMENT" onMatch="DENY" onMismatch="NEUTRAL"/>
                <MarkerFilter marker="LOG4JDBC_OTHER" onMatch="DENY" onMismatch="NEUTRAL"/>
            </Filters>
            <PatternLayout pattern="%clr{%d{yyyy-MM-dd HH:mm:ss.SSS}}{faint} %clr{%5p} %clr{---}{faint} %clr{%c}{cyan} %n%m%n%xwEx"/>
        </Console>
        <RollingFile name="FileAppender" fileName="${LOG_DIR}/sdl-${date:yyyy-MM-dd}-${hostName}.log"
                     filePattern="${LOG_DIR}/sdl/sdl-%d{yyyy-MM-dd}-${hostName}.log">
            <Filters>
                <MarkerFilter marker="LOG4JDBC_SQL" onMatch="ACCEPT" onMismatch="NEUTRAL"/>
                <MarkerFilter marker="LOG4JDBC_EXCEPTION" onMatch="ACCEPT" onMismatch="NEUTRAL"/>
                <MarkerFilter marker="LOG4JDBC_RESULTSETTABLE" onMatch="ACCEPT" onMismatch="NEUTRAL"/>
                <MarkerFilter marker="LOG4JDBC_NON_STATEMENT" onMatch="DENY" onMismatch="NEUTRAL"/>
                <MarkerFilter marker="LOG4JDBC_OTHER" onMatch="DENY" onMismatch="NEUTRAL"/>
            </Filters>
            <PatternLayout>
                <Pattern>[%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %c{1} - %msg%n</Pattern>
            </PatternLayout>
            <Policies>
                <TimeBasedTriggeringPolicy interval="1" modulate="true"/>
            </Policies>
        </RollingFile>
        <RollingFile name="ApprovalAppender" fileName="${LOG_DIR}/approval/approval-${date:yyyy-MM-dd}-${hostName}.log"
                     filePattern="${LOG_DIR}/approval/approval-%d{yyyy-MM-dd}-${hostName}.log">
            <PatternLayout>
                <Pattern>[%-5p] %d{yyyy-MM-dd HH:mm:ss} %c %n%m%n</Pattern>
            </PatternLayout>
            <Policies>
                <TimeBasedTriggeringPolicy interval="1" modulate="true"/>
            </Policies>
        </RollingFile>
        <RollingFile name="AccessLogAppender" fileName="${LOG_DIR}/access/access-${date:yyyy-MM-dd}-${hostName}.log"
                     filePattern="${LOG_DIR}/access/access-%d{yyyy-MM-dd}-${hostName}.log">
            <PatternLayout>
                <Pattern>%d %-5p [%t] %-17c{2} \(%13F:%L\) - %m%n</Pattern>
            </PatternLayout>
            <Policies>
                <TimeBasedTriggeringPolicy interval="1" modulate="true"/>
            </Policies>
        </RollingFile>
        <RollingFile name="UserHistoryAppender" fileName="${LOG_DIR}/history/user-history-${date:yyyy-MM-dd}-${hostName}.log"
                     filePattern="${LOG_DIR}/history/user-history-%d{yyyy-MM-dd}-${hostName}.log">
            <PatternLayout>
                <Pattern>%d %-5p [%t] %-17c{2} \(%13F:%L\) - %m%n</Pattern>
            </PatternLayout>
            <Policies>
                <TimeBasedTriggeringPolicy interval="1" modulate="true"/>
            </Policies>
        </RollingFile>
        <RollingFile name="RoleHistoryAppender" fileName="${LOG_DIR}/history/role-history-${date:yyyy-MM-dd}-${hostName}.log"
                     filePattern="${LOG_DIR}/history/role-history-%d{yyyy-MM-dd}-${hostName}.log">
            <PatternLayout>
                <Pattern>%d %-5p [%t] %-17c{2} \(%13F:%L\) - %m%n</Pattern>
            </PatternLayout>
            <Policies>
                <TimeBasedTriggeringPolicy interval="1" modulate="true"/>
            </Policies>
        </RollingFile>
        <RollingFile name="WorkgroupHistoryAppender"
                     fileName="${LOG_DIR}/history/workgroup-history-${date:yyyy-MM-dd}-${hostName}.log"
                     filePattern="${LOG_DIR}/history/workgroup-history-%d{yyyy-MM-dd}-${hostName}.log">
            <PatternLayout>
                <Pattern>%d %-5p [%t] %-17c{2} \(%13F:%L\) - %m%n</Pattern>
            </PatternLayout>
            <Policies>
                <TimeBasedTriggeringPolicy interval="1" modulate="true"/>
            </Policies>
        </RollingFile>
    </Appenders>

    <Loggers>
        <Logger name="UserHistoryLog" level="INFO" additivity="false">
            <AppenderRef ref="UserHistoryAppender"/>
        </Logger>
        <Logger name="RoleHistoryLog" level="INFO" additivity="false">
            <AppenderRef ref="RoleHistoryAppender"/>
        </Logger>
        <Logger name="WorkgroupHistoryLog" level="INFO" additivity="false">
            <AppenderRef ref="WorkgroupHistoryAppender"/>
        </Logger>
        <Logger name="AccessLog" level="DEBUG" additivity="false">
            <AppenderRef ref="AccessLogAppender"/>
            <AppenderRef ref="ConsoleAppender"/>
        </Logger>
        <Logger name="org.springframework" level="INFO" additivity="false">
            <AppenderRef ref="FileAppender"/>
            <AppenderRef ref="ConsoleAppender"/>
        </Logger>
        <Logger name="com.samsung.approval" level="DEBUG" additivity="false">
            <AppenderRef ref="ApprovalAppender"/>
            <AppenderRef ref="ConsoleAppender"/>
        </Logger>
        <Logger name="com.samsung" level="DEBUG" additivity="false">
            <AppenderRef ref="ConsoleAppender"/>
            <AppenderRef ref="FileAppender"/>
        </Logger>
        <Logger name="com.samsung.excel" level="OFF" additivity="false">
            <AppenderRef ref="ConsoleAppender"/>
            <AppenderRef ref="FileAppender"/>
        </Logger>
        <!-- SQL  Logging Start -->
        <Logger name="log4jdbc.log4j2" level="INFO" additivity="false">
            <AppenderRef ref="ConsoleAppender"/>
            <AppenderRef ref="FileAppender"/>
        </Logger>
        <!-- SQL  Logging End -->
        <Root level="ERROR">
            <AppenderRef ref="ConsoleAppender"/>
            <AppenderRef ref="FileAppender"/>
        </Root>
    </Loggers>
</Configuration>
