当前位置:网站首页>How to specify the output path of pig register Project Log
How to specify the output path of pig register Project Log
2022-06-23 05:55:00 【CaptainCats】
springboot,logback-spring.xml Don't take effect
Usually springboot project ,
Just in src/main/resources Add below logback-spring.xml that will do ,
logback-spring.xml
<?xml version="1.0" encoding="UTF-8"?>
<configuration debug="false" scan="false">
<property name="log.path" value="/opt/pig/logs/${project.artifactId}"/>
<!-- Color log format -->
<property name="CONSOLE_LOG_PATTERN" value="${CONSOLE_LOG_PATTERN:-%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}"/>
<!-- Color log depends on rendering class -->
<conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter"/>
<conversionRule conversionWord="wex" converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter"/>
<conversionRule conversionWord="wEx" converterClass="org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter"/>
<!-- Console log output -->
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>${CONSOLE_LOG_PATTERN}</pattern>
</encoder>
</appender>
<!-- Log file debug output -->
<appender name="debug" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/debug.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${log.path}/%d{yyyy-MM, aux}/debug.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
<maxFileSize>50MB</maxFileSize>
<maxHistory>30</maxHistory>
</rollingPolicy>
<encoder>
<pattern>%date [%thread] %-5level [%logger{50}] %file:%line - %msg%n</pattern>
</encoder>
</appender>
<!-- Log file error output -->
<appender name="error" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/error.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${log.path}/%d{yyyy-MM}/error.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
<maxFileSize>50MB</maxFileSize>
<maxHistory>30</maxHistory>
</rollingPolicy>
<encoder>
<pattern>%date [%thread] %-5level [%logger{50}] %file:%line - %msg%n</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>ERROR</level>
</filter>
</appender>
<!-- Level: FATAL 0 ERROR 3 WARN 4 INFO 6 DEBUG 7 -->
<root level="INFO">
<appender-ref ref="console"/>
<appender-ref ref="debug"/>
<appender-ref ref="error"/>
</root>
</configuration>
Then I started the project , However, it is found that no log files are generated to the configured directory ,
I'm in again application.yml Specified in logback Configuration file for :
logging:
config: classpath:logback-spring.xml
But it still doesn't take effect , What's going on here ?
My project is an open source project pig Registration Center for pig-register, It quoted nacos-core This jar package ,
I feel it is because of this dependence ( Because I start it locally pig-register At the time of C I have seen nacos Output log file ), I went to see naco-core This project , Found that it had a META-INF/logback/nacos.xml,
Inside nacos Of logback The configuration file ,
Then I found it in LoggingSpringApplicationRunListener This configuration file is used in ,
LoggingSpringApplicationRunListener implements SpringApplicationRunListener
See here , I sort of understand what's going on ,
spring boot It's using LoggingApplicationListener To initialize the log system ,
System.setProperty(CONFIG_PROPERTY, DEFAULT_NACOS_LOGBACK_LOCATION);
This step will be LoggingApplicationListener Medium CONFIG_PROPERTY namely logging.config Set up in order to "META-INF/logback/nacos.xml",
And then look at nacos-core Of /META-INF/spring.factories,
Sure enough, it was designated here SpringApplicationRunListener For the front LoggingSpringApplicationRunListener,
such pig-register quote nacos-core When , Will nacos Of LoggingSpringApplicationRunListener Sign up to spring boot In the container ( When it starts ),
such SpringApplicationRunListener I won't go again resource seek logback.xml、logback-spring.xml Such a default configuration file ,
So the configuration file we added doesn't work .
that , Is there no way to modify the log configuration ?
No, it isn't , We can do this at startup :
nohup java -Dserver.port=8848 -Dlogging.level.root=INFO -Xmx256M -Xms256M -jar pig-register.jar --logging.config=classpath:logback-spring.xml >> /dev/null 2>&1 &
Specify to use our configuration file .
Impropriety , Also please correct me .
Reference article :
Gado :SpringBoot And logback-spring.xml Solutions that don't work
cy Tan :logback.xml Don't take effect && spring boot The log configuration file could not be read
kangkaii:spring boot Log file configuration (logback-spring.xml) Close test available !
CaptainCats:META-INF/spring.factories What is the function of documents
CaptainCats:nohup java -jar Background start , Parameters “> /dev/null 2>&1“ The meaning of .
边栏推荐
- 数字藏品到底有什么魔力?目前有哪些靠谱的团队在开发
- Wechat applet: Puzzle toolbox
- A bit of knowledge - folding forging and Damascus steel
- Alibaba cloud ack one and ACK cloud native AI suite have been newly released to meet the needs of the end of the computing era
- C primer plus learning notes - 2. Constant and formatted IO (input / output)
- MySQL面试真题(二十七)——RFM分析法对用户进行分类
- PAT 乙等 1014 C语言
- 制造业数字化转型存在问题及原因分析
- Digital collections - new investment opportunities
- 技能自检 | 想当测试Leader,这6项技能你会吗?
猜你喜欢

Special research on Intelligent upgrading of heavy trucks in China in 2022

How does win11 enable mobile hotspot? How to enable mobile hotspot in win11

技能自检 | 想当测试Leader,这6项技能你会吗?

MySQL面试真题(二十七)——RFM分析法对用户进行分类

Real MySQL interview questions (XXVI) -- didi 2020 written examination questions

数字藏品火热背后需要强大的技术团队支持 北方技术团队

How can digital collections empower economic entities?

True MySQL interview question (21) - Finance - overdue loan

Addressing and addressing units

The 510000 prize pool invites you to participate in the competition -- the second Alibaba cloud ECS cloudbuild developer competition is coming
随机推荐
MySQL面试真题(三十)——贝壳-房产订单分析
Genetic engineering of AI art? Use # artbreeder to change any shape of the image
PAT 乙等 1010 C语言
TCP/IP 详解(第 2 版) 笔记 / 3 链路层 / 3.4 网桥与交换机
opencv显示图像
数字藏品如何赋能经济实体?
数字藏品赋能实体产业释放了哪些利好?
C prime plus notes d'apprentissage - 2, constantes et formatage io (I / o)
Wechat applet: Star Trek spaceship ticket production and generation
Centos7部署radius服务-freeradius-3.0.13-15.el7集成mysql
Wechat applet: future wife query generator
The traditional Internet like platform may no longer exist, and a new industry integrating industrial characteristics and Internet characteristics
Real MySQL interview question (23) -- pinduoduo ball game analysis
visdom的使用
Oracle exception
jvm-06.垃圾回收器
iNFTnews | 加密之家从宇宙寄来的明信片,你会收到哪一张?
Leetcode topic resolution divide two integers
Real MySQL interview question (XXVIII) -- case - Analysis of indicators of communication operators
MySQL面试真题(二十三)——拼多多-球赛分析