标签:类信息 cti oid enter logging err icc ini sql日志
# logback官网
http://logback.qos.ch/manual/index.html
# logback新认识(一):logback主要组件appender、rollingPolicy和triggeringPolicy的使用和理解
http://blog.itcrud.com/blogs/2018/12/logback-first
logback可以编程配置,也可以通过xml或groovy配置文件配置。
logback-test.xml
logback.groovy
logback.xml
META-INF\services\ch.qos.logback.classic.spi.Configurator
文件获取 ch.qos.logback.classic.spi.Configurator
接口的实现类信息。ch.qos.logback.classic.BasicConfigurator
<appender name="pullLog"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>D:\00\03\project.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
<fileNamePattern>D:\00\03\project-%i.log</fileNamePattern>
<minIndex>1</minIndex>
<maxIndex>20</maxIndex>
</rollingPolicy>
<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<maxFileSize>1KB</maxFileSize>
</triggeringPolicy>
<encoder>
<pattern>%date [%thread] %-5level %logger{10} [%file:%line] %msg%n</pattern>
</encoder>
</appender>
<!-- 日志文件 -->
<appender name="SEC"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>D:\00\03\logback.log</file>
<rollingPolicy
class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!--文件的路径与名称,{yyyy-MM-dd HH.mm.ss}精确到秒,则按秒分割保存-->
<FileNamePattern>
D:\00\03\logback.%d{yyyy-MM-dd HH.mm.ss}.log
</FileNamePattern>
<!-- 如果当前是按秒保存,则保存72秒内的日志 -->
<!--<MaxHistory>72</MaxHistory>-->
</rollingPolicy>
<encoder>
<pattern>%date [%thread] %-5level %logger{10} [%file:%line] %msg%n</pattern>
</encoder>
</appender>
如果这一秒中有日志输入,则会触发滚动,没有则不会触发滚动。这一秒的日志文件大小超过指定大小也会触发滚动,按照%i进行索引。
<!-- 日志文件 -->
<appender name="SEC"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<!--当前激活的日志文件-->
<file>D:\00\03\logback.log</file>
<rollingPolicy
class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!--文件的路径与名称,{yyyy-MM-dd HH.mm.ss}精确到秒,则按秒分割保存-->
<FileNamePattern>
D:\00\03\logback.%d{yyyy-MM-dd HH.mm.ss}-%i.log
</FileNamePattern>
<!-- 如果当前是按秒保存,则保存72秒内的日志 -->
<!--<MaxHistory>72</MaxHistory>-->
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>1KB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<encoder>
<pattern>%date [%thread] %-5level %logger{10} [%file:%line] %msg%n</pattern>
</encoder>
</appender>
D:\00\03>tree /f
卷 DATA 的文件夹 PATH 列表
卷序列号为 14DC-019C
D:.
logback.2019-11-24 11.00.27-0.log
logback.2019-11-24 11.00.27-1.log
logback.2019-11-24 11.00.27-2.log
logback.2019-11-24 11.00.27-3.log
logback.2019-11-24 11.00.27-4.log
logback.2019-11-24 11.00.27-5.log
logback.2019-11-24 11.00.27-6.log
logback.2019-11-24 11.00.27-7.log
logback.2019-11-24 11.00.27-8.log
logback.2019-11-24 11.00.27-9.log
logback.2019-11-24 11.00.28-0.log
logback.2019-11-24 11.00.28-1.log
logback.log
# 注意logback.2019-11-24 11.00.27-2.log 并不是保存11.00.27时刻产生的日志文件,而是在这个时刻发生了滚动。
<?xml version="1.0" encoding="UTF-8"?>
<!-- create by ice 2017-09-20 start -->
<configuration>
<contextName>SpringBootLogbacK</contextName>
<property name="LOG_PATH" value="./" />
<!--
<property name="LOG_PATH" value="D:\\JavaWebLogs" />
<property name="APPDIR" value="SpringBootDemo" />
-->
<!--设置系统日志目录-->
<property name="APPDIR" value="SmartCardLog" />
<!-- 日志记录器,日期滚动记录 -->
<appender name="ERROR" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!-- 正在记录的日志文件的路径及文件名 -->
<file>${LOG_PATH}/${APPDIR}/log_error.log</file>
<!-- 日志记录器的滚动策略,按日期,按大小记录 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 归档的日志文件的路径,例如今天是2017-09-21日志,当前写的日志文件路径为file节点指定,可以将此文件与file指定文件路径设置为不同路径,从而将当前日志文件或归档日志文件置不同的目录。
而2017-09-21的日志文件在由fileNamePattern指定。%d{yyyy-MM-dd}指定日期格式,%i指定索引 -->
<fileNamePattern>${LOG_PATH}/${APPDIR}/error/log-error-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
<!-- 除按日志记录之外,还配置了日志文件不能超过2M,若超过2M,日志文件会以索引0开始, 命名日志文件,例如log-error-2017-09-21.0.log -->
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>10MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<!-- 追加方式记录日志 -->
<append>true</append>
<!-- 日志文件的格式 -->
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level [%t] %logger Line:%-3L - %msg%n</pattern>
<charset>utf-8</charset>
</encoder>
<!-- 此日志文件只记录info级别的 -->
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>error</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!-- 日志记录器,日期滚动记录 -->
<appender name="DEBUG" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!-- 正在记录的日志文件的路径及文件名 -->
<file>${LOG_PATH}/${APPDIR}/log_debug.log</file>
<!-- 日志记录器的滚动策略,按日期,按大小记录 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 归档的日志文件的路径,例如今天是2017-09-21日志,当前写的日志文件路径为file节点指定,可以将此文件与file指定文件路径设置为不同路径,从而将当前日志文件或归档日志文件置不同的目录。
而2017-09-21的日志文件在由fileNamePattern指定。%d{yyyy-MM-dd}指定日期格式,%i指定索引 -->
<fileNamePattern>${LOG_PATH}/${APPDIR}/debug/log-debug-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
<!-- 除按日志记录之外,还配置了日志文件不能超过2M,若超过2M,日志文件会以索引0开始,命名日志文件,例如log-error-2017-09-21.0.log -->
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>10MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<!-- 追加方式记录日志 -->
<append>true</append>
<!-- 日志文件的格式 -->
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level [%t] %logger Line:%-3L - %msg%n</pattern>
<charset>utf-8</charset>
</encoder>
<!-- 此日志文件只记录debug级别的 -->
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>debug</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!-- 日志记录器,日期滚动记录 -->
<appender name="INFO" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!-- 正在记录的日志文件的路径及文件名 -->
<file>${LOG_PATH}/${APPDIR}/log_info.log</file>
<!-- 日志记录器的滚动策略,按日期,按大小记录 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 归档的日志文件的路径,例如今天是2017-09-21日志,当前写的日志文件路径为file节点指定,可以将此文件与file指定文件路径设置为不同路径,从而将当前日志文件或归档日志文件置不同的目录。
而2017-09-21的日志文件在由fileNamePattern指定。%d{yyyy-MM-dd}指定日期格式,%i指定索引 -->
<fileNamePattern>${LOG_PATH}/${APPDIR}/info/log-info-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
<!-- 除按日志记录之外,还配置了日志文件不能超过2M,若超过2M,日志文件会以索引0开始, 命名日志文件,例如log-error-2017-09-21.0.log -->
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>10MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<!-- 追加方式记录日志 -->
<append>true</append>
<!-- 日志文件的格式 -->
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level [%t] %logger Line:%-3L - %msg%n</pattern>
<charset>utf-8</charset>
</encoder>
<!-- 此日志文件只记录info级别的 -->
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>info</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!-- 日志记录器,日期滚动记录 -->
<appender name="MYBATIS" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!-- 正在记录的日志文件的路径及文件名 -->
<file>${LOG_PATH}/${APPDIR}/log_mybatis.log</file>
<!-- 日志记录器的滚动策略,按日期,按大小记录 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 归档的日志文件的路径,例如今天是2017-09-21日志,当前写的日志文件路径为file节点指定,可以将此文件与file指定文件路径设置为不同路径,从而将当前日志文件或归档日志文件置不同的目录。
而2017-09-21的日志文件在由fileNamePattern指定。%d{yyyy-MM-dd}指定日期格式,%i指定索引 -->
<fileNamePattern>${LOG_PATH}/${APPDIR}/mybatis/log-mybatis-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
<!-- 除按日志记录之外,还配置了日志文件不能超过2M,若超过2M,日志文件会以索引0开始, 命名日志文件,例如log-mybatis-2017-09-21.0.log -->
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>10MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<!-- 追加方式记录日志 -->
<append>true</append>
<!-- 日志文件的格式 -->
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level [%t] %logger Line:%-3L - %msg%n</pattern>
<charset>utf-8</charset>
</encoder>
<!-- 此日志文件只记录debug级别的 -->
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<!-- <level>trace</level> -->
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<!--encoder 默认配置为PatternLayoutEncoder-->
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level [%t] %logger Line:%-3L - %msg%n</pattern>
<charset>utf-8</charset>
</encoder>
<!--此日志appender是为开发使用,只配置最底级别,控制台输出的日志级别是大于或等于此级别的日志信息-->
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>debug</level>
</filter>
</appender>
<!-- 为单独的包配置日志级别,若root的级别大于此级别, 此处级别也会输出 应用场景:生产环境一般不会将日志级别设置为trace或debug,但是为详细的记录SQL语句的情况, 可将mybatis的级别设置为debug -->
<!-- 配置mybatis打印SQL日志,按包所在目录配置 -->
<logger name="com.yuantiao.smartcardms.dao.mapper" level="debug" additivity="true">
<appender-ref ref="MYBATIS" />
</logger>
<!-- 生产环境下,将此级别配置为适合的级别,以免日志文件太多或影响程序性能 -->
<logger name="com.yuantiao.smartcardms" level="debug" additivity="false">
<appender-ref ref="ERROR" />
<appender-ref ref="DEBUG" />
<appender-ref ref="INFO" />
<!-- 生产环境将请 stdout 去掉 -->
<appender-ref ref="STDOUT" />
</logger>
<!--myibatis log configure-->
<logger name="com.apache.ibatis" level="TRACE"/>
<logger name="java.sql.Connection" level="DEBUG"/>
<logger name="java.sql.Statement" level="DEBUG"/>
<logger name="java.sql.PreparedStatement" level="DEBUG"/>
<root level="DEBUG">
<!-- 生产环境将请 stdout 去掉 -->
<appender-ref ref="STDOUT" />
</root>
</configuration>
使用默认配置类,ch.qos.logback.classic.BasicConfigurator
根日志级别为debug
根日志添加一个ConsoleAppender
,将日志输出到控制台。
日志输出格式类使用 PatternLayoutEncoder
,设置的输出格式为 %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
%d{HH:mm:ss.SSS} 设置日期格式
%thread 线程名
%-5level 日志级别,-: 左对齐,5: 5个字符宽度。
%logger 日志实例名
%msg 日志信息
%n 换行
<pattern>%date %level [%thread] %logger{10} [%file : %line] %msg%n</pattern>
<pattern>【logbck】%blue([requestId:%X{requestId:-syslogId}]) %d{yyyy-MM-dd HH:mm:ss.SSS} %red([%thread]) %5level %n- %msg%n</pattern>
16:06:09.031 [main] INFO chapters.configuration.MyApp1 - Entering application.
16:06:09.046 [main] DEBUG chapters.configuration.Foo - Did it again!
16:06:09.046 [main] INFO chapters.configuration.MyApp1 - Exiting application.
package chapters.configuration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class MyApp1 {
final static Logger logger = LoggerFactory.getLogger(MyApp1.class);
public static void main(String[] args) {
logger.info("Entering application.");
Foo foo = new Foo();
foo.doIt();
logger.info("Exiting application.");
}
}
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<!-- encoders are assigned the type
ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<root level="debug">
<appender-ref ref="STDOUT" />
</root>
</configuration>
http://logback.qos.ch/codes.html#appender_order
appender的定义必须在引用之前。
<configuration>
<appender name="stdout" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-10level %logger{36} %n - %msg%n</pattern>
</encoder>
</appender>
<root level="debug">
<appender-ref ref="stdout"/>
</root>
</configuration>
package com.mozq.logback02.demo;
import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.core.util.StatusPrinter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class Demo2 {
public static void main(String[] args) {
Logger log = LoggerFactory.getLogger("com.mozq.logback02.demo.Demo1");
log.debug("测试logback内部信息");
LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();
StatusPrinter.print(loggerContext);
}
}
13:52:09.105 [main] DEBUG com.mozq.logback02.demo.Demo1
- 测试logback内部信息
13:52:08,877 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback-test.xml]
13:52:08,877 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback.groovy]
# 加载了logback.xml文件
13:52:08,877 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Found resource [logback.xml] at [file:/D:/00/mozq_pro1/shiro/logback-02/target/classes/logback.xml]
13:52:08,989 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - debug attribute not set
13:52:08,990 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.ConsoleAppender]
13:52:09,001 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [stdout]
# encoder使用默认的类型ch.qos.logback.classic.encoder.PatternLayoutEncoder
13:52:09,009 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property
# 设置根日志的级别为debug
13:52:09,100 |-INFO in ch.qos.logback.classic.joran.action.RootLoggerAction - Setting level of ROOT logger to DEBUG
13:52:09,100 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [stdout] to Logger[ROOT]
configuration
元素的 debug属性为true,则会打印logback状态信息。<configuration debug="true">
</configuration>
<configuration>
<statusListener class="ch.qos.logback.core.status.OnConsoleStatusListener" />
</configuration>
不设置扫描间隔默认是1分钟,扫描周期的单位可以是milliseconds, seconds, minutes or hours,不指定默认是milliseconds。
<configuration scan="true">
...
</configuration>
<configuration scan="true" scanPeriod="30 seconds" >
...
</configuration>
http://logback.qos.ch/manual/architecture.html#effectiveLevel
日志实例可以指定级别,logback日志级别定义在 ch.qos.logback.classic.Level
类中。 (TRACE, DEBUG, INFO, WARN and ERROR)。
规则:
日志实例都有一个名称,它们的名称大小写敏感,它们间的继承关系由名称决定。
A logger is said to be an ancestor of another logger if its name followed by a dot is a prefix of the descendant logger name. A logger is said to be a parent of a child logger if there are no ancestors between itself and the descendant logger.
日志实例 "com.foo"
是日志实例 "com.foo.Bar"
的父日志。
日志实例 "java"
是 "java.util"
的父日志,是 "java.util.Vector"
的祖先日志。
日志实例的打印语句,例如 log.info("xx"),这个日志请求的级别为info,日志请求的级别和日志实例的级别不同。
如果日志请求的级别大于等于日志实例的级别,则这个请求是开启的,否则就是关闭的。
logback核心规则日志级别顺序: TRACE < DEBUG < INFO < WARN < ERROR
.
<logger>
元素name
level
additivity
name
必须
level
可选
The value of the level attribute admitting one of the case-insensitive string values TRACE, DEBUG, INFO, WARN, ERROR, ALL or OFF. The special case-insensitive value INHERITED, or its synonym NULL。
additivity
可选 true or false
<appender-ref>
可以有0或多个<appender-ref>
子元素
The <logger>
element may contain zero or more <appender-ref>
elements; each appender thus referenced is added to the named logger. Note that unlike log4j, logback-classic does not close nor remove any previously referenced appenders when configuring a given logger.
<root>
元素root元素表示根日志记录器,它的名字就是 "ROOT",只有一个 level
属性,可以有0或多个<appender-ref>
子元素。
The value of the level attribute can be one of the case-insensitive strings TRACE, DEBUG, INFO, WARN, ERROR, ALL or OFF. Note that the level of the root logger cannot be set to INHERITED or NULL.
Let us note that the basic-selection rule depends on the effective level of the logger being invoked, not the level of the logger where appenders are attached. Logback will first determine whether a logging statement is enabled or not, and if enabled, it will invoke the appenders found in the logger hierarchy, regardless of their level. The configuration file sample4.xml is a case in point:
<configuration>
<appender name="STDOUT"
class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>
%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
</pattern>
</encoder>
</appender>
<logger name="chapters.configuration" level="INFO" />
<!-- turn OFF all logging (children can override) -->
<root level="OFF">
<appender-ref ref="STDOUT" />
</root>
</configuration>
<appender>
元素<appender name=""Y class=""Y>
<layout>*</layout>
<encoder>*</encoder>
<filter>*</filter>
</appender>
An appender is configured with the <appender>
element, which takes two mandatory attributes name and class.
The name attribute specifies the name of the appender whereas the class attribute specifies the fully qualified name of the appender class to instantiate.
The <appender>
element may contain :
zero or one <layout>
elements
zero or more <encoder>
elements
zero or more <filter>
elements
Apart from these three common elements, <appender>
elements may contain any number of elements corresponding to JavaBean properties of the appender class.
Seamlessly supporting any property of a given logback component is one of the major strengths of Joran as discussed in a later chapter. The following diagram illustrates the common structure. Note that support for properties is not visible.
默认情况下Appender是附加的,日志会被输出到当前日志实例所拥有的appender和它的祖先中的appender,因此,如果同一个appender被设置到多个存在继承关系日志实例中,将导致日志重复输出。
日志的附加性并不是有意为新手设置的坑。而是logback的一个特性。
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<logger name="chapters.configuration">
<appender-ref ref="STDOUT" />
</logger>
<root level="debug">
<appender-ref ref="STDOUT" />
</root>
</configuration>
appender被附加到2个日志记录器root和chapters.configuration,chapters.configuration.MyApp3日志记录器没有appender, 默认的附加属性是true,则它的祖先日志记录器root和chapters.configuration有appender,则日志被附加输出到这个appender。
14:25:36.343 [main] INFO chapters.configuration.MyApp3 - Entering application.
14:25:36.343 [main] INFO chapters.configuration.MyApp3 - Entering application.
14:25:36.359 [main] DEBUG chapters.configuration.Foo - Did it again!
14:25:36.359 [main] DEBUG chapters.configuration.Foo - Did it again!
14:25:36.359 [main] INFO chapters.configuration.MyApp3 - Exiting application.
14:25:36.359 [main] INFO chapters.configuration.MyApp3 - Exiting application.
additivity
属性设置为false,则日志实例的日志只会打印到它关联的appender,不会同时打印到它的祖先关联的appender。
<configuration>
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>foo.log</file>
<encoder>
<pattern>%date %level [%thread] %logger{10} [%file : %line] %msg%n</pattern>
</encoder>
</appender>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%msg%n</pattern>
</encoder>
</appender>
<logger name="chapters.configuration.Foo" additivity="false">
<appender-ref ref="FILE" />
</logger>
<root level="debug">
<appender-ref ref="STDOUT" />
</root>
</configuration>
<configuration>
<property resource="resource1.properties" />
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>${USER_HOME}/myApp.log</file>
<encoder>
<pattern>%msg%n</pattern>
</encoder>
</appender>
<root level="debug">
<appender-ref ref="FILE" />
</root>
</configuration>
USER_HOME=D:/mozq
<configuration>
<property name="USER_HOME" value="/home/sebastien" />
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>${USER_HOME}/myApp.log</file>
<encoder>
<pattern>%msg%n</pattern>
</encoder>
</appender>
<root level="debug">
<appender-ref ref="FILE" />
</root>
</configuration>
Filename pattern [D:/00/03/logback.%d{yyyy-MM-dd HH.mm.ss}-%i.log] contains an integer token converter, i.e. %i, INCOMPATIBLE with this configuration. Remove it.
<FileNamePattern>
D:\00\03\logback.%d{yyyy-MM-dd HH.mm.ss}-%i.log
</FileNamePattern>
标签:类信息 cti oid enter logging err icc ini sql日志
原文地址:https://www.cnblogs.com/mozq/p/11921639.html