当前位置:网站首页>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 .
边栏推荐
- MySQL面试真题(二十九)——案例-找到爱看的电影
- jvm-04.对象的内存布局
- Leetcode topic analysis add binary
- MySQL面试真题(三十)——贝壳-房产订单分析
- Wechat applet: unfashionable love talk
- 数字藏品如何赋能经济实体?
- Yingjixin ip5566 with type-C port 3A charging and discharging fast charging mobile power supply 5W wireless charging in one SOC
- 工作积累-判断GPS是否打开
- Centos7部署radius服务-freeradius-3.0.13-15.el7集成mysql
- 如何指定pig-register项目日志的输出路径
猜你喜欢

Real MySQL interview question (23) -- pinduoduo ball game analysis

C primer plus learning notes - 2. Constant and formatted IO (input / output)
![[proteus simulation] Arduino uno+pcf8574+lcd1602+mpx4250 electronic scale](/img/2d/96a370c90dcb7091038afad33bc4b4.png)
[proteus simulation] Arduino uno+pcf8574+lcd1602+mpx4250 electronic scale

Wechat applet: a new interesting test

Skill self check | do you know these 6 skills if you want to be a test leader?

编址和编址单位

Software design and Development Notes 2: serial port debugging tool based on QT design

jvm-05.垃圾回收

Prometheus, incluxdb2.2 installation and flume_ Export download compile use

runc 符号链接挂载与容器逃逸漏洞预警(CVE-2021-30465)
随机推荐
Adnroid activity screenshot save display to album view display picture animation disappear
Oracle exception
How can digital collections empower economic entities?
jvm-05.垃圾回收
关于安装pip3 install chatterbot报错的问题
MySQL面试真题(二十九)——案例-找到爱看的电影
Wechat applet: elderly blessing short video
jvm-06.垃圾回收器
Advanced Mathematics (Seventh Edition) Tongji University exercises 1-9 personal solutions
Leetcode topic resolution divide two integers
MySQL面试真题(二十六)——滴滴2020年笔试题
如何指定pig-register项目日志的输出路径
Android handler memory leak kotlin memory leak handling
Activity启动模式和生命周期实测结果
MySQL面试真题(二十五)——常见的分组比较场景
Skill self check | do you know these 6 skills if you want to be a test leader?
数字藏品赋能实体产业释放了哪些利好?
APP SHA1获取程序 百度地图 高德地图获取SHA1值的简单程序
使用链表实现两个多项式相加和相乘
Software design and Development Notes 2: serial port debugging tool based on QT design