<?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_datanode_error.log</file>
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <fileNamePattern>${IOTDB_HOME}/logs/log-datanode-error-%d{yyyyMMdd}.log.gz</fileNamePattern>
            <maxHistory>30</maxHistory>
        </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_datanode_warn.log</file>
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <fileNamePattern>${IOTDB_HOME}/logs/log-datanode-warn-%d{yyyyMMdd}.log.gz</fileNamePattern>
            <maxHistory>30</maxHistory>
        </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="FILEDEBUG">
        <file>${IOTDB_HOME}/logs/log_datanode_debug.log</file>
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <fileNamePattern>${IOTDB_HOME}/logs/log-datanode-debug-%d{yyyyMMdd}.log.gz</fileNamePattern>
            <maxHistory>30</maxHistory>
        </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_datanode_trace.log</file>
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <fileNamePattern>${IOTDB_HOME}/logs/log-datanode-trace-%d{yyyyMMdd}.log.gz</fileNamePattern>
            <maxHistory>30</maxHistory>
        </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_datanode_all.log</file>
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <fileNamePattern>${IOTDB_HOME}/logs/log-datanode-all-%d{yyyyMMdd}.log.gz</fileNamePattern>
            <maxHistory>30</maxHistory>
        </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_datanode_measure.log</file>
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <fileNamePattern>${IOTDB_HOME}/logs/log-datanode-measure-%d{yyyyMMdd}.log.gz</fileNamePattern>
            <maxHistory>30</maxHistory>
        </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_datanode_audit.log</file>
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <fileNamePattern>${IOTDB_HOME}/logs/log-datanode-audit-%d{yyyyMMdd}.log.gz</fileNamePattern>
            <maxHistory>30</maxHistory>
        </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_datanode_query_debug.log</file>
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <fileNamePattern>${IOTDB_HOME}/logs/log-datanode-query-debug-%d{yyyyMMdd}.log.gz</fileNamePattern>
            <maxHistory>30</maxHistory>
        </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_datanode_slow_sql.log</file>
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <fileNamePattern>${IOTDB_HOME}/logs/log-datanode-slow-sql-%d{yyyyMMdd}.log.gz</fileNamePattern>
            <maxHistory>30</maxHistory>
        </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_datanode_query_frequency.log</file>
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <fileNamePattern>${IOTDB_HOME}/logs/log-datanode-query-frequency-%d{yyyyMMdd}.log.gz</fileNamePattern>
            <maxHistory>30</maxHistory>
        </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_datanode_compaction.log</file>
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <fileNamePattern>${IOTDB_HOME}/logs/log-datanode-compaction-%d{yyyyMMdd}.log.gz</fileNamePattern>
            <maxHistory>30</maxHistory>
        </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="PIPE">
        <file>${IOTDB_HOME}/logs/log_datanode_pipe.log</file>
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <fileNamePattern>${IOTDB_HOME}/logs/log-datanode-pipe-%d{yyyyMMdd}.log.gz</fileNamePattern>
            <maxHistory>30</maxHistory>
        </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="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="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>
    <logger level="info" name="org.apache.iotdb.pipe.api">
        <appender-ref ref="PIPE"/>
    </logger>
    <logger level="info" name="org.apache.iotdb.db.pipe">
        <appender-ref ref="PIPE"/>
    </logger>
    <logger level="info" name="org.apache.iotdb.commons.pipe">
        <appender-ref ref="PIPE"/>
    </logger>
</configuration>
