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

    <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>./logs/indic-search-service.log</file>
        <encoder>
            <charset>UTF-8</charset>
            <pattern>%date{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36}:%line - %msg%n</pattern>
        </encoder>
        <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
            <fileNamePattern>
                ./logs/indic-search-service.%i.log
            </fileNamePattern>
            <minIndex>1</minIndex>
            <maxIndex>10</maxIndex>
        </rollingPolicy>
        <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
            <maxFileSize>500MB</maxFileSize>
        </triggeringPolicy>
    </appender>
    <appender name="FILE-ECS" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>./logs/json/indic-search-service.log</file>

        <encoder class="net.logstash.logback.encoder.LogstashEncoder">
            <customFields>{"service":{"name":"indic-search-service"}}</customFields>

            <fieldNames>
                <timestamp>@timestamp</timestamp>
                <level>log.level</level>
                <logger>log.logger</logger>
                <thread>process.thread.name</thread>
                <message>message</message>
            </fieldNames>

            <includeCallerData>true</includeCallerData>
        </encoder>
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <fileNamePattern>./logs/json/indic-search-service-json.%d{yyyy-MM-dd}.%i.gz
            </fileNamePattern>
            <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
                <maxFileSize>100MB</maxFileSize>
            </timeBasedFileNamingAndTriggeringPolicy>
            <maxHistory>10</maxHistory>
        </rollingPolicy>
    </appender>

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

    <root level="error">
        <appender-ref ref="FILE-ECS"/>
    </root>

    <logger name="ru.nbch" level="debug" additivity="false">
        <appender-ref ref="FILE"/>
        <appender-ref ref="CONSOLE"/>
    </logger>
    <logger name="org.hibernate.engine.jdbc.spi.SqlExceptionHelper" level="ERROR"/>
</configuration>