1
suenlai 2021 年 6 月 10 日
这个时候日志相关的 bean 还没有加载进来,springboot 好像有种机制是先把要打印的放在缓冲区, 等加载完后再打印。
|
3
suenlai 2021 年 6 月 10 日
Deferred Log that can be used to store messages that shouldn't be written until the logging system is fully initialized.
你参考下这个 API:Deferred Log |
4
suenlai 2021 年 6 月 10 日
deferred log 在 logback 初始化前用的是 commons-logging
" The name (<code>commons-logging.properties</code>) of the properties file to search for. " |
5
Aruforce 2021 年 6 月 10 日
在 main 方法执行 application run 之前就使用 logger 。。。这样 logger 就在 application 启动之前启动了
|
6
Aruforce 2021 年 6 月 10 日
@Aruforce 比如 logback 这种...但是 spring-logback.xml 和 logback.xml 不知道能不能共存..有个不确定的问题是 spring logger starter 会不会对 logback reconfigure... 如果不能的话。。spring-logback.xml 就没啥用了
|
7
wz497345846 2021 年 6 月 10 日
写在 bootstrap.yml 里面
|
9
luxinfl OP @wz497345846 这个只是配置文件会优先读到吧
|
11
Aruforce 2021 年 6 月 10 日
@luxinfl 因为你在使用 SpringBoot 我假定你在使用 spring-logback.xml 做日志组件的配置。。但是 logback 本身是默认读取 logback.xml 的。。。所以在 Springboot 对 logback 配置完成之前 logback 是在使用自己的默认配置...
你可以增加一个 logback.xml 并且里面有你自己的格式配置 这个可能要求配置参数不能依赖 springprofile...来验证 |
12
Aruforce 2021 年 6 月 10 日
@Aruforce 或者你可以看看 LoggingApplicationListener SpringBootJoranConfigurator LoggingSystem LogbackLoggingSystem 这几个类。。。我是以前大略看过..不过大体启动逻辑和一些默认配置 就在这些类里面
|
13
Amit 2021 年 6 月 10 日
log 组件是不依赖 spring 容器的,spring 启动后会通过 log 组件的 api 更新日志级别和格式,所以我猜启动的时候应该是用的默认格式
|