`
san_yun
  • 浏览: 2662472 次
  • 来自: 杭州
文章分类
社区版块
存档分类
最新评论

logback如何发现configuration file

 
阅读更多

今天发现日志一直打印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)

 

分享到:
评论

相关推荐

    logback所需jar包

    <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> <file>logs/app.log</file> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <fileNamePattern>...

    logback.的jar包

    <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" /> ...

    logback类库.rar

    <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" /> ...

    logback测试

    <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" /> </...

    logback的使用和logback.xml详解

    <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" /> </...

    logback-demo.rar

    <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" /> </...

    logback-demo项目日志记录

    <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找不到

    docker安装nacos报错nacos-logback.xml找不到,把该文件放入相应的文件夹中即可

    spring boot logback 实现

    Logback作为Spring Boot的默认日志系统,提供了强大的日志管理和输出功能。本教程将深入讲解如何在Spring Boot项目中配置和使用Logback,实现日志的info和error级别分类存放,以及每日生成新的日志文件。 首先,...

    logback相关jar包

    <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" /> </...

    Logback中文文档

    <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" /> ...

    LogBack.zip

    <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" /> ...

    logback-0.9.18.zip

    <file>logback.log</file> <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n <appender-ref ref="FILE" /> </configuration> ``` **性能优化** Logback 在性能方面表现出色,...

    logback日志配置demo

    <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 添加到 `...

    logback日志配置

    <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_...

    ssm整合logback

    <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" /> ...

    logback使用方法

    <appender name="ROLLING_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> <file>logs/app.log</file> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> ...

    logback相关jar包和demo代码.zip

    <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" /> ...

    采用slf4j+logback输出日志

    <appender name="FILE" class="ch.qos.logback.core.FileAppender"> <file>myApp.log</file> <pattern>%date %level [%thread] %logger{10} [%file:%line] %msg%n ``` 7. **日志级别管理** 日志级别通常...

    SpringBoot-logback

    <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> <file>logs/app.log</file> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> ...

Global site tag (gtag.js) - Google Analytics