<?xml version="1.0" encoding="UTF-8"?>
<configuration>

    <!-- File appender for persistent logs -->
    <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>${user.home}/.askimo/logs/askimo-cli.log</file>
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <!-- Daily rollover -->
            <fileNamePattern>${user.home}/.askimo/logs/askimo-cli.%d{yyyy-MM-dd}.log</fileNamePattern>
            <!-- Keep 7 days of history -->
            <maxHistory>7</maxHistory>
            <!-- Cap total log size at 100MB -->
            <totalSizeCap>100MB</totalSizeCap>
        </rollingPolicy>
        <encoder>
            <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
        </encoder>
    </appender>

    <!-- Async appender for better performance -->
    <appender name="ASYNC" class="ch.qos.logback.classic.AsyncAppender">
        <queueSize>512</queueSize>
        <appender-ref ref="FILE" />
    </appender>


    <!-- Askimo application logging - controlled by LOGBACK_LEVEL env var -->
    <logger name="io.askimo" level="${LOGBACK_LEVEL:-INFO}"/>

    <!-- Root logger configuration - default to ERROR for all packages -->
    <root level="ERROR">
        <appender-ref ref="ASYNC" />
    </root>
</configuration>

