当前位置:网站首页>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 .
边栏推荐
- Advanced Mathematics (Seventh Edition) Tongji University exercises 1-8 personal solutions
- A bit of knowledge - folding forging and Damascus steel
- 制造业数字化转型存在问题及原因分析
- 数字藏品到底有什么魔力?目前有哪些靠谱的团队在开发
- Heimdall database proxy scale out 20 times
- How can digital collections empower economic entities?
- C primer plus學習筆記 —— 2、常量與格式化IO(輸入/輸出)
- PAT 乙等 1018 C语言
- Real MySQL interview question (XXVIII) -- case - Analysis of indicators of communication operators
- 如何指定pig-register项目日志的输出路径
猜你喜欢

The performance of nonstandard sprintf code in different platforms

How can digital collections empower economic entities?

Wechat applet: Puzzle toolbox

Use of visdom

iNFTnews | 加密之家从宇宙寄来的明信片,你会收到哪一张?

Raspberry pie assert preliminary exercise

MySQL面试真题(二十五)——常见的分组比较场景

Data migration from dolphin scheduler 1.2.1 to dolphin scheduler 2.0.5 and data test records after migration

jvm-06.垃圾回收器

MySQL面试真题(二十九)——案例-找到爱看的电影
随机推荐
HierarchyViewer工具找不到 HierarchyViewer位置
node中操作mongoDB
MySQL character set
iNFTnews | 加密之家从宇宙寄来的明信片,你会收到哪一张?
MySQL面试真题(二十七)——RFM分析法对用户进行分类
visdom的使用
【数据库备份】通过定时任务完成MySQL数据库的备份
Genetic engineering of AI art? Use # artbreeder to change any shape of the image
Wechat applet: Puzzle toolbox
mysql字符集
Wechat applet; AI intelligent dubbing assistant
A bit of knowledge - folding forging and Damascus steel
Activity启动模式和生命周期实测结果
True MySQL interview question (XXII) -- condition screening and grouping screening after table connection
AHA C language Chapter 8 game time is up (lesson 29)
C primer plus學習筆記 —— 2、常量與格式化IO(輸入/輸出)
MySQL面试真题(二十九)——案例-找到爱看的电影
Deploy docker and install MySQL in centos7
Visdom draws multiple dynamic loss curves
Management system of borrowed books based on SSM framework