当前位置:网站首页>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 .
边栏推荐
- Excel sheet column number for leetcode topic resolution
- PAT 乙等 1017 C语言
- MySQL面试真题(二十六)——滴滴2020年笔试题
- PAT 乙等 1023 组个最小数
- Centos7部署radius服务-freeradius-3.0.13-15.el7集成mysql
- vant weapp日历组件性能优化 Calendar 日历添加min-date最小日期页面加载缓慢
- Three most advanced certifications, two innovative technologies and two outstanding cases, Alibaba cloud appeared at the cloud native industry conference
- True MySQL interview question (24) -- row column exchange
- What does the English letter PC mean? What does the Internet PC mean
- Opencv display image
猜你喜欢

True question of MySQL interview (29) -- case - finding favorite movies

Wechat applet: elderly blessing short video

Huawei's software and hardware ecosystem has taken shape, fundamentally changing the leading position of the United States in the software and hardware system

How can digital collections empower economic entities?

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

数字藏品——新的投资机遇

C primer plus學習筆記 —— 2、常量與格式化IO(輸入/輸出)

数字化工厂建设可划分为三个方面

Real MySQL interview questions (25) -- common group comparison scenarios

Wireshark TS | 视频 APP 无法播放问题
随机推荐
MySQL面试真题(二十七)——RFM分析法对用户进行分类
APP SHA1获取程序 百度地图 高德地图获取SHA1值的简单程序
数字藏品到底有什么魔力?目前有哪些靠谱的团队在开发
Lottery DDD code
工作积累-判断GPS是否打开
阿里云对象存储oss+picgo+typora实现构建图床
JS interview question - anti shake function
Advanced Mathematics (Seventh Edition) Tongji University exercises 1-7 personal solutions
Three most advanced certifications, two innovative technologies and two outstanding cases, Alibaba cloud appeared at the cloud native industry conference
[proteus simulation] Arduino uno+pcf8574+lcd1602+mpx4250 electronic scale
The traditional Internet like platform may no longer exist, and a new industry integrating industrial characteristics and Internet characteristics
Heimdall database proxy scale out 20 times
PAT 乙等 1020.月饼
PAT 乙等 1015 C语言
ORB_ Slam2 operation
ArcTime 制作中英文字幕视频
编址和编址单位
jvm-01.指令重排
Special research on Intelligent upgrading of heavy trucks in China in 2022
Work accumulation - judge whether GPS is on