<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <springProperty scope="context" name="logFile" source="logging.file.name" defaultValue="logs/app.log"/>

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

  <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
    <file>${logFile}</file>
    <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
      <fileNamePattern>${logFile}.%d{yyyy-MM-dd}.gz</fileNamePattern>
      <maxHistory>30</maxHistory>
    </rollingPolicy>
    <encoder>
      <pattern>%d{yyyy-MM-dd HH:mm:ss} %-5level [%thread] %logger{36} - %msg%n</pattern>
    </encoder>
  </appender>

  <appender name="ACTIVITY_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
    <file>logs/activity.log</file>
    <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
      <fileNamePattern>logs/activity.%d{yyyy-MM-dd}.gz</fileNamePattern>
      <maxHistory>90</maxHistory>
    </rollingPolicy>
    <encoder>
      <pattern>%d{yyyy-MM-dd HH:mm:ss} %msg%n</pattern>
    </encoder>
  </appender>

  <logger name="activity" level="INFO" additivity="false">
    <appender-ref ref="ACTIVITY_FILE"/>
  </logger>

  <logger name="com.petshop" level="${LOG_LEVEL:-INFO}"/>
  <logger name="org.springframework.security" level="${LOG_LEVEL_SECURITY:-WARN}"/>

  <root level="INFO">
    <appender-ref ref="CONSOLE"/>
    <appender-ref ref="FILE"/>
  </root>
</configuration>
