spring boot 配置log模組
阿新 • • 發佈:2018-12-29
<?xml version="1.0" encoding="UTF-8"?> <configuration> <property name="USER_BEHAVIOR_PATH" value="base-project"/> <!-- 檔案輸出格式 --> <property name="PATTERN" value="%-12(%d{yyyy-MM-dd HH:mm:ss.SSS}) |-%-5level [%thread] %c [%L] -| %msg%n"/> <property name="USER_BEHAVIOR_PATTERN" value="%-12(%d{yyyy-MM-dd HH:mm:ss.SSS}) | %msg%n"/> <!-- 開發環境 --> <!--<springProfile name="dev">--> <!--<springProfile name="dev">--> <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender"> <encoder> <pattern>${PATTERN}</pattern> </encoder> </appender> <appender name="userBehavior" class="ch.qos.logback.core.rolling.RollingFileAppender"> <file>${USER_BEHAVIOR_PATH}/logs/user_behavior.log</file> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <fileNamePattern>${USER_BEHAVIOR_PATH}/logs/base-project-%d{yyyy-MM-dd}.log</fileNamePattern> </rollingPolicy> <encoder> <pattern>${USER_BEHAVIOR_PATTERN}</pattern> </encoder> </appender> <logger name="com.jecy.base" level="debug"/> <root level="info"> <appender-ref ref="CONSOLE"/> </root> </configuration>
(1) 標籤就不講了,網上查查應該都用 在釋出的時候需要將
<appender-ref ref="CONSOLE"/> 配置成 <appender-ref ref="userBehavior"/>
(2) application.yml 配置
server: port: 8099 logging: level: com.jecy.base.baseproject.base.mapper: debug com.dgjy.purewater.model.entity: debug config: classpath:logback-boot.xml