<?xml version="1.0" encoding="UTF-8"?>
<configuration debug="true">
    <property resource="commons.properties"/>
    <property file="/opt/metersphere/conf/metersphere.properties"/>
    <appender name="console" class="ch.qos.logback.core.ConsoleAppender">
        <encoder>
            <pattern>%d %5p %40.40c:%4L - %m%n</pattern>
        </encoder>
    </appender>

    <appender name="debugAppender"
              class="ch.qos.logback.core.rolling.RollingFileAppender">
        <filter class="ch.qos.logback.classic.filter.LevelFilter">
            <level>DEBUG</level>
            <onMatch>ACCEPT</onMatch>
            <onMismatch>DENY</onMismatch>
        </filter>
        <File>${logging.file.path}/debug.log</File>
        <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
            <FileNamePattern>${logging.file.path}/history/debug.%d{yyyyMMdd}-%i.log</FileNamePattern>
            <maxHistory>${logger.max.history:-30}</maxHistory>
            <maxFileSize>50MB</maxFileSize>
        </rollingPolicy>
        <encoder>
            <charset>UTF-8</charset>
            <Pattern>%d [%thread] %-5level %logger{36} %line - %msg%n</Pattern>
        </encoder>
    </appender>

    <appender name="infoAppender"
              class="ch.qos.logback.core.rolling.RollingFileAppender">
        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
            <level>INFO</level>
        </filter>
        <File>${logging.file.path}/info.log</File>
        <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
            <FileNamePattern>${logging.file.path}/history/info.%d{yyyyMMdd}-%i.log</FileNamePattern>
            <maxHistory>${logger.max.history:-30}</maxHistory>
            <maxFileSize>50MB</maxFileSize>
        </rollingPolicy>
        <encoder>
            <charset>UTF-8</charset>
            <Pattern>%d [%thread] %-5level %logger{36} %line - %msg%n</Pattern>
        </encoder>
    </appender>

    <appender name="errorAppender"
              class="ch.qos.logback.core.rolling.RollingFileAppender">
        <filter class="ch.qos.logback.classic.filter.LevelFilter">
            <level>ERROR</level>
            <onMatch>ACCEPT</onMatch>
            <onMismatch>DENY</onMismatch>
        </filter>

        <File>${logging.file.path}/error.log</File>
        <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
            <FileNamePattern>${logging.file.path}/history/error.%d{yyyyMMdd}-%i.log</FileNamePattern>
            <maxHistory>${logger.max.history:-30}</maxHistory>
            <maxFileSize>50MB</maxFileSize>
        </rollingPolicy>
        <encoder>
            <charset>UTF-8</charset>
            <Pattern>%d [%thread] %-5level %logger{36} %line - %msg%n</Pattern>
        </encoder>
    </appender>

    <appender name="warnAppender"
              class="ch.qos.logback.core.rolling.RollingFileAppender">
        <filter class="ch.qos.logback.classic.filter.LevelFilter">
            <level>WARN</level>
            <onMatch>ACCEPT</onMatch>
            <onMismatch>DENY</onMismatch>
        </filter>
        <File>${logging.file.path}/warn.log</File>
        <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
            <FileNamePattern>${logging.file.path}/history/warn.%d{yyyyMMdd}-%i.log</FileNamePattern>
            <maxHistory>${logger.max.history:-30}</maxHistory>
            <maxFileSize>50MB</maxFileSize>
        </rollingPolicy>
        <encoder>
            <charset>UTF-8</charset>
            <Pattern>%d [%thread] %-5level %logger{36} %line - %msg%n</Pattern>
        </encoder>
    </appender>

    <appender name="consoleAsyncAppender" class="ch.qos.logback.classic.AsyncAppender">
        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
            <level>DEBUG</level>
        </filter>
        <queueSize>10000</queueSize>
        <appender-ref ref="console"/>
    </appender>

    <appender name="debugAsyncAppender" class="ch.qos.logback.classic.AsyncAppender">
        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
            <level>DEBUG</level>
        </filter>
        <queueSize>10000</queueSize>
        <appender-ref ref="debugAppender"/>
    </appender>

    <appender name="infoAsyncAppender" class="ch.qos.logback.classic.AsyncAppender">
        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
            <level>INFO</level>
        </filter>
        <queueSize>10000</queueSize>
        <appender-ref ref="infoAppender"/>
    </appender>

    <appender name="errorAsyncAppender" class="ch.qos.logback.classic.AsyncAppender">
        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
            <level>ERROR</level>
        </filter>
        <queueSize>10000</queueSize>
        <includeCallerData>true</includeCallerData>
        <appender-ref ref="errorAppender"/>
    </appender>

    <appender name="warnAsyncAppender" class="ch.qos.logback.classic.AsyncAppender">
        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
            <level>WARN</level>
        </filter>
        <queueSize>10000</queueSize>
        <includeCallerData>true</includeCallerData>
        <appender-ref ref="warnAppender"/>
    </appender>

    <!-- 自定义api-test模块日志 -->
    <appender name="apiAppender"
              class="ch.qos.logback.core.rolling.RollingFileAppender">
        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
            <level>INFO</level>
        </filter>
        <File>${logging.file.path}/api-test.log</File>
        <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
            <FileNamePattern>${logging.file.path}/history/api-test.%d{yyyyMMdd}-%i.log</FileNamePattern>
            <maxHistory>${logger.max.history:-30}</maxHistory>
            <maxFileSize>50MB</maxFileSize>
        </rollingPolicy>
        <encoder>
            <charset>UTF-8</charset>
            <Pattern>%d %t %-5level %logger{36} %line - %msg%n</Pattern>
        </encoder>
    </appender>
    <appender name="apiTestAppender" class="ch.qos.logback.classic.AsyncAppender">
        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
            <level>INFO</level>
        </filter>
        <queueSize>10000</queueSize>
        <appender-ref ref="apiAppender"/>
    </appender>
    <logger name="io.metersphere.api" additivity="false" level="${logger.level:INFO}">
        <appender-ref ref="apiTestAppender"/>
    </logger>

    <!-- 自定义load-test模块日志 -->
    <appender name="loadAppender"
              class="ch.qos.logback.core.rolling.RollingFileAppender">
        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
            <level>INFO</level>
        </filter>
        <File>${logging.file.path}/load-test.log</File>
        <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
            <FileNamePattern>${logging.file.path}/history/load-test.%d{yyyyMMdd}-%i.log</FileNamePattern>
            <maxHistory>${logger.max.history:-30}</maxHistory>
            <maxFileSize>50MB</maxFileSize>
        </rollingPolicy>
        <encoder>
            <charset>UTF-8</charset>
            <Pattern>%d %t %-5level %logger{36} %line - %msg%n</Pattern>
        </encoder>
    </appender>
    <appender name="loadTestAppender" class="ch.qos.logback.classic.AsyncAppender">
        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
            <level>INFO</level>
        </filter>
        <queueSize>10000</queueSize>
        <appender-ref ref="loadAppender"/>
    </appender>
    <logger name="io.metersphere.load" additivity="false" level="${logger.level:INFO}">
        <appender-ref ref="loadTestAppender"/>
    </logger>

    <!-- 自定义project-management模块日志 -->
    <appender name="projectAppender"
              class="ch.qos.logback.core.rolling.RollingFileAppender">
        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
            <level>INFO</level>
        </filter>
        <File>${logging.file.path}/project.log</File>
        <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
            <FileNamePattern>${logging.file.path}/history/project.%d{yyyyMMdd}-%i.log
            </FileNamePattern>
            <maxHistory>${logger.max.history:-30}</maxHistory>
            <maxFileSize>50MB</maxFileSize>
        </rollingPolicy>
        <encoder>
            <charset>UTF-8</charset>
            <Pattern>%d %t %-5level %logger{36} %line - %msg%n</Pattern>
        </encoder>
    </appender>
    <appender name="projectManagementAppender" class="ch.qos.logback.classic.AsyncAppender">
        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
            <level>INFO</level>
        </filter>
        <queueSize>10000</queueSize>
        <appender-ref ref="projectAppender"/>
    </appender>
    <logger name="io.metersphere.project" additivity="false" level="${logger.level:INFO}">
        <appender-ref ref="projectManagementAppender"/>
    </logger>


    <!-- 自定义system-setting模块日志 -->
    <appender name="systemAppender"
              class="ch.qos.logback.core.rolling.RollingFileAppender">
        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
            <level>INFO</level>
        </filter>
        <File>${logging.file.path}/system-setting.log</File>
        <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
            <FileNamePattern>${logging.file.path}/history/system-setting.%d{yyyyMMdd}-%i.log
            </FileNamePattern>
            <maxHistory>${logger.max.history:-30}</maxHistory>
            <maxFileSize>50MB</maxFileSize>
        </rollingPolicy>
        <encoder>
            <charset>UTF-8</charset>
            <Pattern>%d %t %-5level %logger{36} %line - %msg%n</Pattern>
        </encoder>
    </appender>
    <appender name="systemSettingAppender" class="ch.qos.logback.classic.AsyncAppender">
        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
            <level>INFO</level>
        </filter>
        <queueSize>10000</queueSize>
        <appender-ref ref="systemAppender"/>
    </appender>
    <logger name="io.metersphere.system" additivity="false" level="${logger.level:INFO}">
        <appender-ref ref="systemSettingAppender"/>
    </logger>

    <!-- 自定义test-plan模块日志 -->
    <appender name="testPlanAppender"
              class="ch.qos.logback.core.rolling.RollingFileAppender">
        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
            <level>INFO</level>
        </filter>
        <File>${logging.file.path}/test-plan.log</File>
        <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
            <FileNamePattern>${logging.file.path}/history/test-plan.%d{yyyyMMdd}-%i.log
            </FileNamePattern>
            <maxHistory>${logger.max.history:-30}</maxHistory>
            <maxFileSize>50MB</maxFileSize>
        </rollingPolicy>
        <encoder>
            <charset>UTF-8</charset>
            <Pattern>%d %t %-5level %logger{36} %line - %msg%n</Pattern>
        </encoder>
    </appender>
    <appender name="testPlanRefAppender" class="ch.qos.logback.classic.AsyncAppender">
        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
            <level>INFO</level>
        </filter>
        <queueSize>10000</queueSize>
        <appender-ref ref="testPlanAppender"/>
    </appender>
    <logger name="io.metersphere.plan" additivity="false" level="${logger.level:INFO}">
        <appender-ref ref="testPlanRefAppender"/>
    </logger>

    <!-- 自定义case-management模块日志 -->
    <appender name="testTrackAppender"
              class="ch.qos.logback.core.rolling.RollingFileAppender">
        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
            <level>INFO</level>
        </filter>
        <File>${logging.file.path}/case-management.log</File>
        <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
            <FileNamePattern>${logging.file.path}/history/case-management.%d{yyyyMMdd}-%i.log</FileNamePattern>
            <maxHistory>${logger.max.history:-30}</maxHistory>
            <maxFileSize>50MB</maxFileSize>
        </rollingPolicy>
        <encoder>
            <charset>UTF-8</charset>
            <Pattern>%d %t %-5level %logger{36} %line - %msg%n</Pattern>
        </encoder>
    </appender>
    <appender name="testTrackRefAppender" class="ch.qos.logback.classic.AsyncAppender">
        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
            <level>INFO</level>
        </filter>
        <queueSize>10000</queueSize>
        <appender-ref ref="testTrackAppender"/>
    </appender>
    <logger name="io.metersphere.track" additivity="false" level="${logger.level:INFO}">
        <appender-ref ref="testTrackRefAppender"/>
    </logger>


    <!-- 自定义ui-test模块日志 -->
    <appender name="uiTestAppender"
              class="ch.qos.logback.core.rolling.RollingFileAppender">
        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
            <level>INFO</level>
        </filter>
        <File>${logging.file.path}/ui-test.log</File>
        <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
            <FileNamePattern>${logging.file.path}/history/ui-test.%d{yyyyMMdd}-%i.log</FileNamePattern>
            <maxHistory>${logger.max.history:-30}</maxHistory>
            <maxFileSize>50MB</maxFileSize>
        </rollingPolicy>
        <encoder>
            <charset>UTF-8</charset>
            <Pattern>%d %t %-5level %logger{36} %line - %msg%n</Pattern>
        </encoder>
    </appender>
    <appender name="uiTestRefAppender" class="ch.qos.logback.classic.AsyncAppender">
        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
            <level>INFO</level>
        </filter>
        <queueSize>10000</queueSize>
        <appender-ref ref="uiTestAppender"/>
    </appender>
    <logger name="io.metersphere.ui" additivity="false" level="${logger.level:INFO}">
        <appender-ref ref="uiTestRefAppender"/>
    </logger>


    <!-- 自定义workstation模块日志 -->
    <appender name="workstationAppender"
              class="ch.qos.logback.core.rolling.RollingFileAppender">
        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
            <level>INFO</level>
        </filter>
        <File>${logging.file.path}/workstation.log</File>
        <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
            <FileNamePattern>${logging.file.path}/history/workstation.%d{yyyyMMdd}-%i.log</FileNamePattern>
            <maxHistory>${logger.max.history:-30}</maxHistory>
            <maxFileSize>50MB</maxFileSize>
        </rollingPolicy>
        <encoder>
            <charset>UTF-8</charset>
            <Pattern>%d %t %-5level %logger{36} %line - %msg%n</Pattern>
        </encoder>
    </appender>
    <appender name="workstationRefAppender" class="ch.qos.logback.classic.AsyncAppender">
        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
            <level>INFO</level>
        </filter>
        <queueSize>10000</queueSize>
        <appender-ref ref="workstationAppender"/>
    </appender>
    <logger name="io.metersphere.workstation" additivity="false" level="${logger.level:INFO}">
        <appender-ref ref="workstationRefAppender"/>
    </logger>

    <!-- 自定义bug模块日志 -->
    <appender name="bugAppender"
              class="ch.qos.logback.core.rolling.RollingFileAppender">
        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
            <level>INFO</level>
        </filter>
        <File>${logging.file.path}/bug.log</File>
        <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
            <FileNamePattern>${logging.file.path}/history/bug.%d{yyyyMMdd}-%i.log</FileNamePattern>
            <maxHistory>${logger.max.history:-30}</maxHistory>
            <maxFileSize>50MB</maxFileSize>
        </rollingPolicy>
        <encoder>
            <charset>UTF-8</charset>
            <Pattern>%d %t %-5level %logger{36} %line - %msg%n</Pattern>
        </encoder>
    </appender>
    <appender name="bugRefAppender" class="ch.qos.logback.classic.AsyncAppender">
        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
            <level>INFO</level>
        </filter>
        <queueSize>10000</queueSize>
        <appender-ref ref="bugAppender"/>
    </appender>
    <logger name="io.metersphere.bug" additivity="false" level="${logger.level:INFO}">
        <appender-ref ref="bugRefAppender"/>
    </logger>

    <!-- 自定义API执行过程日志 -->
    <appender name="apiRunLogAppender"
              class="ch.qos.logback.core.rolling.RollingFileAppender">
        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
            <level>INFO</level>
        </filter>
        <File>${logging.file.path}/ms-jmeter-run.log</File>
        <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
            <FileNamePattern>${logging.file.path}/history/ms-jmeter-run-log.%d{yyyyMMdd}-%i.log</FileNamePattern>
            <maxHistory>${logger.max.history:-30}</maxHistory>
            <maxFileSize>50MB</maxFileSize>
        </rollingPolicy>
        <encoder>
            <charset>UTF-8</charset>
            <Pattern>%d %t %-5level %logger{36} %line - %msg%n</Pattern>
        </encoder>
    </appender>
    <appender name="runLogAppender" class="ch.qos.logback.classic.AsyncAppender">
        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
            <level>INFO</level>
        </filter>
        <queueSize>10000</queueSize>
        <appender-ref ref="apiRunLogAppender"/>
    </appender>
    <logger name="ms-jmeter-run-log" additivity="false" level="${logger.level:INFO}">
        <appender-ref ref="runLogAppender"/>
    </logger>

    <!-- 自定义JMETER输出日志 -->
    <appender name="JMETER_LOG" class="io.metersphere.api.jmeter.JMeterLoggerAppender"/>

    <root level="INFO">
        <appender-ref ref="infoAsyncAppender"/>
        <appender-ref ref="console"/>
    </root>
    <!--将JMETER日志单独输出的包路径-->
    <logger name="org.apache.jmeter" additivity="false" level="INFO">
        <appender-ref ref="JMETER_LOG"/>
    </logger>
    <logger name="io.metersphere" additivity="false" level="${logger.level:INFO}">
        <appender-ref ref="infoAsyncAppender"/>
        <appender-ref ref="warnAsyncAppender"/>
        <appender-ref ref="errorAsyncAppender"/>
    </logger>
    <!--  包名不支持通配符 * ，这里需要每个模块固定好mapper  -->
    <logger name="io.metersphere.sdk.mapper" level="${logger.sql.level}">
        <appender-ref ref="console"/>
    </logger>

    <logger name="io.metersphere.ApiApplication" additivity="false" level="${logger.level:INFO}">
        <appender-ref ref="infoAsyncAppender"/>
    </logger>

</configuration>
