今天发现日志一直打印debug没有加载configuration file中配置的格式,通过debug找到logback记载配置的流程。
当调用
org.slf4j.LoggerFactory.getLogger(StandaloneLoggingModule.class)
的调用过程如下:
--->LoggerFactory.getLogger(Class clazz) --->iLoggerFactory=slf4j.LoggerFactory.getILoggerFactory() --->slf4j.LoggerFactory.performInitialization() --->slf4j.LoggerFactory.bind() --->org.slf4j.impl.StaticLoggerBinder.getSingleton() --->org.slf4j.impl.StaticLoggerBinder.init() --->new ch.qos.logback.classic.util.ContextInitializer(defaultLoggerContext).autoConfig() --->iLoggerFactory.getLogger(name)
ch.qos.logback.classic.util.ContextInitializer.autoConfig()执行过程
--->ContextInitializer.findURLOfDefaultConfigurationFile(true) --->ContextInitializer.findConfigFileURLFromSystemProperties(myClassLoader, updateStatus); ---> String logbackConfigFile =OptionHelper.getSystemProperty("logback.configurationFile"); ---> URL result = new URL(logbackConfigFile); ---> 如果出现MalformedURLException, result = Loader.getResource(logbackConfigFile, classLoader) --> ContextInitializer.configureByResource(url)
相关推荐
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> <file>logs/app.log</file> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <fileNamePattern>...
<appender name="FILE" class="ch.qos.logback.core.FileAppender"> <file>logs/app.log</file> <pattern>%date %level [%thread] %logger{10} [%file:%line] %msg%n <appender-ref ref="FILE" /> ...
<appender name="FILE" class="ch.qos.logback.core.FileAppender"> <file>logs/app.log</file> <pattern>%date %level [%thread] %logger{10} [%file:%line] %msg%n <appender-ref ref="FILE" /> ...
<appender name="FILE" class="ch.qos.logback.core.FileAppender"> <file>app.log</file> <pattern>%date %level [%thread] %logger{10} [%file:%line] %msg%n <appender-ref ref="FILE" /> </...
<appender name="FILE" class="ch.qos.logback.core.FileAppender"> <file>log.log</file> <pattern>%date %level [%thread] %logger{10} [%file:%line] %msg%n <appender-ref ref="FILE" /> </...
<appender name="FILE" class="ch.qos.logback.core.FileAppender"> <file>myApp.log</file> <pattern>%date %level [%thread] %logger{10} [%file:%line] %msg%n <appender-ref ref="FILE" /> </...
<file>logback-demo.log</file> <pattern>%date %level [%thread] %logger{10} [%file:%line] %msg%n <appender-ref ref="FILE" /> </configuration> ``` 这段配置会将日志同时输出到控制台和`...
docker安装nacos报错nacos-logback.xml找不到,把该文件放入相应的文件夹中即可
Logback作为Spring Boot的默认日志系统,提供了强大的日志管理和输出功能。本教程将深入讲解如何在Spring Boot项目中配置和使用Logback,实现日志的info和error级别分类存放,以及每日生成新的日志文件。 首先,...
<appender name="FILE" class="ch.qos.logback.core.FileAppender"> <file>myApp.log</file> <pattern>%date %level [%thread] %logger{10} [%file:%line] %msg%n <appender-ref ref="FILE" /> </...
<appender name="FILE" class="ch.qos.logback.core.FileAppender"> <file>logs/app.log</file> <pattern>%date %level [%thread] %logger{10} [%file:%line] %msg%n <appender-ref ref="FILE" /> ...
<appender name="FILE" class="ch.qos.logback.core.FileAppender"> <file>logs/app.log</file> <pattern>%date %level [%thread] %logger{10} [%file:%line] %msg%n <appender-ref ref="FILE" /> ...
<file>logback.log</file> <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n <appender-ref ref="FILE" /> </configuration> ``` **性能优化** Logback 在性能方面表现出色,...
<appender name="FILE" class="ch.qos.logback.core.FileAppender"> <file>logs/app.log</file> <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n ``` 然后将 `FILE` appender 添加到 `...
<appender name="file" class="ch.qos.logback.core.rolling.RollingFileAppender"> <file>${LOG_HOME}/today.log</file> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> ${LOG_...
<appender name="FILE" class="ch.qos.logback.core.FileAppender"> <file>logs/app.log</file> <pattern>%date %level [%thread] %logger{10} [%file:%line] %msg%n <appender-ref ref="FILE" /> ...
<appender name="ROLLING_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> <file>logs/app.log</file> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> ...
<appender name="FILE" class="ch.qos.logback.core.FileAppender"> <file>logs/app.log</file> <pattern>%date %level [%thread] %logger{10} [%file:%line] %msg%n <appender-ref ref="FILE" /> ...
<appender name="FILE" class="ch.qos.logback.core.FileAppender"> <file>myApp.log</file> <pattern>%date %level [%thread] %logger{10} [%file:%line] %msg%n ``` 7. **日志级别管理** 日志级别通常...
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> <file>logs/app.log</file> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> ...