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

    Licensed to the Apache Software Foundation (ASF) under one
    or more contributor license agreements.  See the NOTICE file
    distributed with this work for additional information
    regarding copyright ownership.  The ASF licenses this file
    to you under the Apache License, Version 2.0 (the
    "License"); you may not use this file except in compliance
    with the License.  You may obtain a copy of the License at

        http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing,
    software distributed under the License is distributed on an
    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    KIND, either express or implied.  See the License for the
    specific language governing permissions and limitations
    under the License.

-->
<configuration scan="true" scanPeriod="60 seconds">
    <jmxConfigurator/>
    <!-- prevent logback from outputting its own status at the start of every log -->
    <statusListener class="ch.qos.logback.core.status.NopStatusListener"/>
    <appender class="ch.qos.logback.core.rolling.RollingFileAppender" name="FILEERROR">
        <file>${IOTDB_HOME}/logs/log_error.log</file>
        <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
            <fileNamePattern>${IOTDB_HOME}/logs/log-error-%d{yyyyMMdd}.%i.log.gz</fileNamePattern>
            <maxFileSize>10MB</maxFileSize>
            <maxHistory>168</maxHistory>
            <totalSizeCap>512MB</totalSizeCap>
        </rollingPolicy>
        <append>true</append>
        <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
            <pattern>%d [%t] %-5p %C{25}:%L - %m %n</pattern>
            <charset>utf-8</charset>
        </encoder>
        <filter class="ch.qos.logback.classic.filter.LevelFilter">
            <level>error</level>
            <onMatch>ACCEPT</onMatch>
            <onMismatch>DENY</onMismatch>
        </filter>
    </appender>
    <appender class="ch.qos.logback.core.rolling.RollingFileAppender" name="FILEWARN">
        <file>${IOTDB_HOME}/logs/log_warn.log</file>
        <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
            <fileNamePattern>${IOTDB_HOME}/logs/log-warn-%d{yyyyMMdd}.%i.log.gz</fileNamePattern>
            <maxFileSize>10MB</maxFileSize>
            <maxHistory>168</maxHistory>
            <totalSizeCap>512MB</totalSizeCap>
        </rollingPolicy>
        <append>true</append>
        <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
            <pattern>%d [%t] %-5p %C{25}:%L - %m %n</pattern>
            <charset>utf-8</charset>
        </encoder>
        <filter class="ch.qos.logback.classic.filter.LevelFilter">
            <level>WARN</level>
            <onMatch>ACCEPT</onMatch>
            <onMismatch>DENY</onMismatch>
        </filter>
    </appender>
    <appender class="ch.qos.logback.core.rolling.RollingFileAppender" name="FILEINFO">
        <file>${IOTDB_HOME}/logs/log_info.log</file>
        <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
            <fileNamePattern>${IOTDB_HOME}/logs/log-info-%d{yyyyMMdd}.%i.log.gz</fileNamePattern>
            <maxFileSize>50MB</maxFileSize>
            <maxHistory>168</maxHistory>
            <totalSizeCap>5GB</totalSizeCap>
        </rollingPolicy>
        <append>true</append>
        <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
            <pattern>%d [%t] %-5p %C{25}:%L - %m %n</pattern>
            <charset>utf-8</charset>
        </encoder>
        <filter class="ch.qos.logback.classic.filter.LevelFilter">
            <level>INFO</level>
            <onMatch>ACCEPT</onMatch>
            <onMismatch>DENY</onMismatch>
        </filter>
    </appender>
    <appender class="ch.qos.logback.core.rolling.RollingFileAppender" name="FILEDEBUG">
        <file>${IOTDB_HOME}/logs/log_debug.log</file>
        <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
            <fileNamePattern>${IOTDB_HOME}/logs/log-debug-%d{yyyyMMdd}.%i.log.gz</fileNamePattern>
            <maxFileSize>50MB</maxFileSize>
            <maxHistory>168</maxHistory>
            <totalSizeCap>5GB</totalSizeCap>
        </rollingPolicy>
        <append>true</append>
        <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
            <pattern>%d [%t] %-5p %C{25}:%L - %m %n</pattern>
            <charset>utf-8</charset>
        </encoder>
        <filter class="ch.qos.logback.classic.filter.LevelFilter">
            <level>DEBUG</level>
            <onMatch>ACCEPT</onMatch>
            <onMismatch>DENY</onMismatch>
        </filter>
    </appender>
    <appender class="ch.qos.logback.core.rolling.RollingFileAppender" name="FILETRACE">
        <file>${IOTDB_HOME}/logs/log_trace.log</file>
        <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
            <fileNamePattern>${IOTDB_HOME}/logs/log-trace-%d{yyyyMMdd}.%i.log.gz</fileNamePattern>
            <maxFileSize>50MB</maxFileSize>
            <maxHistory>168</maxHistory>
            <totalSizeCap>5GB</totalSizeCap>
        </rollingPolicy>
        <append>true</append>
        <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
            <pattern>%d [%t] %-5p %C{25}:%L - %m %n</pattern>
            <charset>utf-8</charset>
        </encoder>
        <filter class="ch.qos.logback.classic.filter.LevelFilter">
            <level>TRACE</level>
            <onMatch>ACCEPT</onMatch>
            <onMismatch>DENY</onMismatch>
        </filter>
    </appender>
    <appender class="ch.qos.logback.core.ConsoleAppender" name="stdout">
        <Target>System.out</Target>
        <encoder>
            <pattern>%d [%t] %-5p %C{25}:%L - %m %n</pattern>
            <charset>utf-8</charset>
        </encoder>
        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
            <level>${CONSOLE_LOG_LEVEL:-DEBUG}</level>
        </filter>
    </appender>
    <!-- a log appender that collect all log records whose level is greater than debug-->
    <appender class="ch.qos.logback.core.rolling.RollingFileAppender" name="FILEALL">
        <file>${IOTDB_HOME}/logs/log_all.log</file>
        <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
            <fileNamePattern>${IOTDB_HOME}/logs/log-all-%d{yyyyMMdd}.%i.log.gz</fileNamePattern>
            <maxFileSize>50MB</maxFileSize>
            <maxHistory>168</maxHistory>
            <totalSizeCap>5GB</totalSizeCap>
        </rollingPolicy>
        <append>true</append>
        <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
            <pattern>%d [%t] %-5p %C{25}:%L - %m %n</pattern>
            <charset>utf-8</charset>
        </encoder>
        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
            <level>INFO</level>
        </filter>
    </appender>
    <appender class="ch.qos.logback.core.rolling.RollingFileAppender" name="FILE_COST_MEASURE">
        <file>${IOTDB_HOME}/logs/log_measure.log</file>
        <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
            <fileNamePattern>${IOTDB_HOME}/logs/log-measure-%d{yyyyMMdd}.%i.log.gz</fileNamePattern>
            <maxFileSize>10MB</maxFileSize>
            <maxHistory>168</maxHistory>
            <totalSizeCap>512MB</totalSizeCap>
        </rollingPolicy>
        <append>true</append>
        <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
            <pattern>%d [%t] %-5p %C{25}:%L - %m %n</pattern>
            <charset>utf-8</charset>
        </encoder>
        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
            <level>INFO</level>
        </filter>
    </appender>
    <appender class="ch.qos.logback.core.rolling.RollingFileAppender" name="SYNC">
        <file>${IOTDB_HOME}/logs/log_sync.log</file>
        <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
            <fileNamePattern>${IOTDB_HOME}/logs/log-sync-%d{yyyyMMdd}.%i.log.gz</fileNamePattern>
            <maxFileSize>10MB</maxFileSize>
            <maxHistory>168</maxHistory>
            <totalSizeCap>512MB</totalSizeCap>
        </rollingPolicy>
        <append>true</append>
        <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
            <pattern>%d [%t] %-5p %C{25}:%L - %m %n</pattern>
            <charset>utf-8</charset>
        </encoder>
        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
            <level>INFO</level>
        </filter>
    </appender>
    <appender class="ch.qos.logback.core.rolling.RollingFileAppender" name="AUDIT">
        <file>${IOTDB_HOME}/logs/log_audit.log</file>
        <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
            <fileNamePattern>${IOTDB_HOME}/logs/log-audit-%d{yyyyMMdd}.%i.log.gz</fileNamePattern>
            <maxFileSize>10MB</maxFileSize>
            <maxHistory>168</maxHistory>
            <totalSizeCap>512MB</totalSizeCap>
        </rollingPolicy>
        <append>true</append>
        <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
            <pattern>%d [%t] %-5p %C{25}:%L - %m %n</pattern>
            <charset>utf-8</charset>
        </encoder>
        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
            <level>INFO</level>
        </filter>
    </appender>
    <appender class="ch.qos.logback.core.rolling.RollingFileAppender" name="QUERY_DEBUG">
        <file>${IOTDB_HOME}/logs/log_query_debug.log</file>
        <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
            <fileNamePattern>${IOTDB_HOME}/logs/log-query-debug-%d{yyyyMMdd}.%i.log.gz</fileNamePattern>
            <maxFileSize>10MB</maxFileSize>
            <maxHistory>168</maxHistory>
            <totalSizeCap>512MB</totalSizeCap>
        </rollingPolicy>
        <append>true</append>
        <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
            <pattern>%d [%t] %-5p %C{25}:%L - %m %n</pattern>
            <charset>utf-8</charset>
        </encoder>
        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
            <level>INFO</level>
        </filter>
    </appender>
    <appender class="ch.qos.logback.core.rolling.RollingFileAppender" name="SLOW_SQL">
        <file>${IOTDB_HOME}/logs/log_slow_sql.log</file>
        <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
            <fileNamePattern>${IOTDB_HOME}/logs/log-slow-sql-%d{yyyyMMdd}.%i.log.gz</fileNamePattern>
            <maxFileSize>10MB</maxFileSize>
            <maxHistory>168</maxHistory>
            <totalSizeCap>512MB</totalSizeCap>
        </rollingPolicy>
        <append>true</append>
        <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
            <pattern>%d [%t] %-5p %C{25}:%L - %m %n</pattern>
            <charset>utf-8</charset>
        </encoder>
        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
            <level>INFO</level>
        </filter>
    </appender>
    <appender class="ch.qos.logback.core.rolling.RollingFileAppender" name="QUERY_FREQUENCY">
        <file>${IOTDB_HOME}/logs/log_query_frequency.log</file>
        <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
            <fileNamePattern>${IOTDB_HOME}/logs/log-query-frequency-%d{yyyyMMdd}.%i.log.gz</fileNamePattern>
            <maxFileSize>10MB</maxFileSize>
            <maxHistory>168</maxHistory>
            <totalSizeCap>512MB</totalSizeCap>
        </rollingPolicy>
        <append>true</append>
        <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
            <pattern>%d [%t] %-5p %C{25}:%L - %m %n</pattern>
            <charset>utf-8</charset>
        </encoder>
        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
            <level>INFO</level>
        </filter>
    </appender>
    <appender class="ch.qos.logback.core.rolling.RollingFileAppender" name="COMPACTION">
        <file>${IOTDB_HOME}/logs/log_compaction.log</file>
        <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
            <fileNamePattern>${IOTDB_HOME}/logs/log-compaction-%d{yyyyMMdd}.%i.log.gz</fileNamePattern>
            <maxFileSize>10MB</maxFileSize>
            <maxHistory>168</maxHistory>
            <totalSizeCap>512MB</totalSizeCap>
        </rollingPolicy>
        <append>true</append>
        <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
            <pattern>%d [%t] %-5p %C{25}:%L - %m %n</pattern>
            <charset>utf-8</charset>
        </encoder>
        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
            <level>INFO</level>
        </filter>
    </appender>
    <root level="info">
        <appender-ref ref="FILETRACE"/>
        <appender-ref ref="FILEDEBUG"/>
        <appender-ref ref="FILEWARN"/>
        <appender-ref ref="FILEERROR"/>
        <appender-ref ref="FILEINFO"/>
        <appender-ref ref="FILEALL"/>
        <appender-ref ref="stdout"/>
    </root>
    <logger level="OFF" name="io.moquette.broker.metrics.MQTTMessageLogger"/>
    <logger level="info" name="org.apache.iotdb.db.service"/>
    <logger level="info" name="org.apache.iotdb.db.conf"/>
    <logger level="info" name="org.apache.iotdb.db.cost.statistic">
        <appender-ref ref="FILE_COST_MEASURE"/>
    </logger>
    <logger level="info" name="org.apache.iotdb.db.sync">
        <appender-ref ref="SYNC"/>
    </logger>
    <logger level="info" name="IoTDB_AUDIT_LOGGER">
        <appender-ref ref="AUDIT"/>
    </logger>
    <logger level="info" name="QUERY_DEBUG">
        <appender-ref ref="QUERY_DEBUG"/>
    </logger>
    <logger level="info" name="SLOW_SQL">
        <appender-ref ref="SLOW_SQL"/>
    </logger>
    <logger level="info" name="QUERY_FREQUENCY">
        <appender-ref ref="QUERY_FREQUENCY"/>
    </logger>
    <logger level="info" name="DETAILED_FAILURE_QUERY_TRACE"/>
    <logger level="info" name="COMPACTION">
        <appender-ref ref="COMPACTION"/>
    </logger>
</configuration>
