<?xml version="1.0" encoding="UTF-8"?>
<configuration>
	<define name="LOG_PATH" class="stirling.software.SPDF.config.LogbackPropertyLoader" />

    <!-- Console Appender -->
    <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
        <encoder>
            <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
        </encoder>
    </appender>

    <!-- Rolling File Appender for Auth Logs -->
    <appender name="AUTHLOG" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>${LOG_PATH}/invalid-auths.log</file>
        <encoder>
            <pattern>%d %p %c{1} [%thread] %m%n</pattern>
        </encoder>
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <fileNamePattern>${LOG_PATH}/auth-%d{yyyy-MM-dd}.log</fileNamePattern>
            <maxHistory>1</maxHistory>
        </rollingPolicy>
    </appender>

    <!-- Rolling File Appender for General Logs -->
    <appender name="GENERAL" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>${LOG_PATH}/info.log</file>
        <encoder>
            <pattern>%d %p %c{1} [%thread] %m%n</pattern>
        </encoder>
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <fileNamePattern>${LOG_PATH}/info-%d{yyyy-MM-dd}.log</fileNamePattern>
            <maxHistory>1</maxHistory>
        </rollingPolicy>
    </appender>

    <!-- Root Logger -->
    <root level="INFO">
        <appender-ref ref="CONSOLE"/>
        <appender-ref ref="GENERAL"/>
    </root>

    <!-- Specific Logger -->
    <logger name="stirling.software.proprietary.security.CustomAuthenticationFailureHandler"
            level="ERROR" additivity="false">
        <appender-ref ref="CONSOLE"/>
        <appender-ref ref="AUTHLOG"/>
    </logger>
</configuration>
