<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="60 seconds" debug="false">
    <!-- 日志存放路径 -->
    <property name="log.path" value="logs/ems-dev-adapter" />
    <!-- 日志输出格式 -->
    <property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n" />

    <!-- 控制台输出（docker logs 看到的就是这个） -->
    <appender name="console" class="ch.qos.logback.core.ConsoleAppender">
        <encoder>
            <pattern>${log.pattern}</pattern>
        </encoder>
    </appender>

    <!-- 全局错误日志 -->
    <appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>${log.path}/error.log</file>
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <fileNamePattern>${log.path}/error.%d{yyyy-MM-dd}.log</fileNamePattern>
            <maxHistory>60</maxHistory>
        </rollingPolicy>
        <encoder>
            <pattern>${log.pattern}</pattern>
        </encoder>
        <filter class="ch.qos.logback.classic.filter.LevelFilter">
            <level>ERROR</level>
            <onMatch>ACCEPT</onMatch>
            <onMismatch>DENY</onMismatch>
        </filter>
    </appender>

    <!-- ===================== 各模块独立日志 ===================== -->
    <!-- 公共模块 -->
    <appender name="common_appender" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>${log.path}/common.log</file>
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <fileNamePattern>${log.path}/common.%d{yyyy-MM-dd}.log</fileNamePattern>
            <maxHistory>60</maxHistory>
        </rollingPolicy>
        <encoder><pattern>${log.pattern}</pattern></encoder>
    </appender>
    <!-- 安科瑞 -->
    <appender name="acrel_appender" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>${log.path}/acrel.log</file>
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <fileNamePattern>${log.path}/acrel.%d{yyyy-MM-dd}.log</fileNamePattern>
            <maxHistory>60</maxHistory>
        </rollingPolicy>
        <encoder><pattern>${log.pattern}</pattern></encoder>
    </appender>
    <!-- BA楼控 -->
    <appender name="ba_appender" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>${log.path}/ba.log</file>
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <fileNamePattern>${log.path}/ba.%d{yyyy-MM-dd}.log</fileNamePattern>
            <maxHistory>60</maxHistory>
        </rollingPolicy>
        <encoder><pattern>${log.pattern}</pattern></encoder>
    </appender>
    <!-- 充电桩 -->
    <appender name="charging_appender" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>${log.path}/charging.log</file>
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <fileNamePattern>${log.path}/charging.%d{yyyy-MM-dd}.log</fileNamePattern>
            <maxHistory>60</maxHistory>
        </rollingPolicy>
        <encoder><pattern>${log.pattern}</pattern></encoder>
    </appender>
    <!-- GeekOpen断路器 -->
    <appender name="geekopen_appender" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>${log.path}/geekopen.log</file>
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <fileNamePattern>${log.path}/geekopen.%d{yyyy-MM-dd}.log</fileNamePattern>
            <maxHistory>60</maxHistory>
        </rollingPolicy>
        <encoder><pattern>${log.pattern}</pattern></encoder>
    </appender>
    <!-- 古瑞瓦特光伏 -->
    <appender name="growatt_appender" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>${log.path}/growatt.log</file>
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <fileNamePattern>${log.path}/growatt.%d{yyyy-MM-dd}.log</fileNamePattern>
            <maxHistory>60</maxHistory>
        </rollingPolicy>
        <encoder><pattern>${log.pattern}</pattern></encoder>
    </appender>
    <!-- keka开关 -->
    <appender name="keka_appender" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>${log.path}/keka.log</file>
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <fileNamePattern>${log.path}/keka.%d{yyyy-MM-dd}.log</fileNamePattern>
            <maxHistory>60</maxHistory>
        </rollingPolicy>
        <encoder><pattern>${log.pattern}</pattern></encoder>
    </appender>
    <!-- 广场灯控 -->
    <appender name="squarelight_appender" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>${log.path}/squarelight.log</file>
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <fileNamePattern>${log.path}/squarelight.%d{yyyy-MM-dd}.log</fileNamePattern>
            <maxHistory>60</maxHistory>
        </rollingPolicy>
        <encoder><pattern>${log.pattern}</pattern></encoder>
    </appender>

    <!-- ===================== 包绑定 + 控制台输出全开 ===================== -->
    <logger name="com.ruoyi.ems.acrel" level="info" additivity="false">
        <appender-ref ref="acrel_appender" />
        <appender-ref ref="console" />
        <appender-ref ref="file_error" />
    </logger>
    <logger name="com.ruoyi.ems.ba" level="info" additivity="false">
        <appender-ref ref="ba_appender" />
        <appender-ref ref="console" />
        <appender-ref ref="file_error" />
    </logger>
    <logger name="com.ruoyi.ems.charging" level="info" additivity="false">
        <appender-ref ref="charging_appender" />
        <appender-ref ref="console" />
        <appender-ref ref="file_error" />
    </logger>
    <logger name="com.ruoyi.ems.common" level="info" additivity="false">
        <appender-ref ref="common_appender" />
        <appender-ref ref="console" />
        <appender-ref ref="file_error" />
    </logger>
    <logger name="com.ruoyi.ems.geekopen" level="info" additivity="false">
        <appender-ref ref="geekopen_appender" />
        <appender-ref ref="console" />
        <appender-ref ref="file_error" />
    </logger>
    <logger name="com.ruoyi.ems.growatt" level="info" additivity="false">
        <appender-ref ref="growatt_appender" />
        <appender-ref ref="console" />
        <appender-ref ref="file_error" />
    </logger>
    <logger name="com.ruoyi.ems.keka" level="info" additivity="false">
        <appender-ref ref="keka_appender" />
        <appender-ref ref="console" />
        <appender-ref ref="file_error" />
    </logger>
    <logger name="com.ruoyi.ems.squarelgt" level="info" additivity="false">
        <appender-ref ref="squarelight_appender" />
        <appender-ref ref="console" />
        <appender-ref ref="file_error" />
    </logger>

    <!-- 基础包日志 -->
    <logger name="com.ruoyi" level="info" />
    <logger name="org.springframework" level="warn" />

    <!-- root 只保留控制台 + 错误日志 -->
    <root level="info">
        <appender-ref ref="console" />
        <appender-ref ref="file_error" />
    </root>
</configuration>