我有一个logback.xml
文件,用于配置应该如何在我的 Spring Boot 应用程序中完成日志记录。我想将其更改为.properties
文件。但我找不到任何文件。
<?xml version="1.0" encoding="UTF-8"?>
<property name="LOG_FILE" value="${user.home}/my_logs/logs"/>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>INFO</level>
</filter>
<layout class="ch.qos.logback.classic.PatternLayout">
<Pattern>
%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger %c:%L - %msg%n
</Pattern>
</layout>
</appender>
<appender name="FILE-AUDIT"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>DEBUG</level>
</filter>
<file>${LOG_FILE}-debug.log</file>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<Pattern>
%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger %c:%L - %msg%n
</Pattern>
</encoder>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- rollover weekly -->
<fileNamePattern>${LOG_FILE}-debug.%d{yyyy-MM-dd}.%i.log
</fileNamePattern>
<maxHistory>7</maxHistory>
<timeBasedFileNamingAndTriggeringPolicy
class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>10MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
</appender>
<appender name="FILE-ERROR"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>ERROR</level>
</filter>
<file>${LOG_FILE}-error.log</file>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<Pattern>
%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger %c:%L - %msg%n
</Pattern>
</encoder>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- rollover weekly -->
<fileNamePattern>${LOG_FILE}-error.%d{yyyy-MM-dd}.%i.log
</fileNamePattern>
<maxHistory>7</maxHistory>
<timeBasedFileNamingAndTriggeringPolicy
class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>10MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
</appender>
<appender name="FILE-INFO"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>INFO</level>
</filter>
<file>${LOG_FILE}-info.log</file>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<Pattern>
%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger %c:%L - %msg%n
</Pattern>
</encoder>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- rollover weekly -->
<fileNamePattern>${LOG_FILE}-info.%d{yyyy-MM-dd}.%i.log
</fileNamePattern>
<maxHistory>7</maxHistory>
<timeBasedFileNamingAndTriggeringPolicy
class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>10MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
</appender>
<root level="ALL">
<appender-ref ref="STDOUT"/>
<appender-ref ref="FILE-AUDIT"/>
<appender-ref ref="FILE-ERROR"/>
<appender-ref ref="FILE-INFO"/>
</root>
<logger name="com.*******.*****.webservices" level="DEBUG"/>
<logger name="org.springframework" level="WARN"/>
<logger name="springfox.documentation" level="WARN"/>
<logger name="org.hibernate" level="ERROR"/>
<logger name="org.apache.http" level="WARN"/>
<logger name="org.apache.activemq" level="WARN"/>
<logger name="com.zaxxer.hikari" level="WARN"/>
<logger name="net.sf.ehcache" level="WARN"/>
<logger name="org.apache.velocity" level="WARN"/>
<logger name="com.amazonaws" level="WARN"/>
<logger name="org.apache.tomcat" level="WARN"/>
如何将上述.xml
文件转换为.properties
文件。是否有任何可用的文档或示例。我有一个显示如何配置log4j.properties
文件的文档,我可以使用相同的吗?