mirror of
http://git.pig4cloud.com/pig/pigx.git
synced 2026-11-08 04:39:00 +08:00
✨ 添加新特性。日志自动维护到spring boot admin web console
This commit is contained in:
1 parent
23babe67a9
commit
439dceb9ba
3 files changed
+28
-1
No files matched your search
+24
@@ -0,0 +1,24 @@
|
||||
package com.pig4cloud.pigx.common.log.init;
|
||||
|
||||
import org.springframework.context.ApplicationContextInitializer;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.core.env.ConfigurableEnvironment;
|
||||
|
||||
/**
|
||||
* @author lengleng
|
||||
* @date 2019-05-22
|
||||
* <p>
|
||||
* 初始化日志路径
|
||||
*/
|
||||
public class ApplicationLoggerInitializer implements ApplicationContextInitializer<ConfigurableApplicationContext> {
|
||||
@Override
|
||||
public void initialize(ConfigurableApplicationContext applicationContext) {
|
||||
ConfigurableEnvironment environment = applicationContext.getEnvironment();
|
||||
|
||||
String appName = environment.getProperty("spring.application.name");
|
||||
|
||||
String logBase = environment.getProperty("LOGGING_PATH", "logs");
|
||||
// spring boot admin 直接加载日志
|
||||
System.setProperty("logging.file", String.format("%s/%s/debug.log", logBase, appName));
|
||||
}
|
||||
}
|
||||
@@ -1,2 +1,4 @@
|
||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
||||
com.pig4cloud.pigx.common.log.LogAutoConfiguration
|
||||
org.springframework.context.ApplicationContextInitializer=\
|
||||
com.pig4cloud.pigx.common.log.init.ApplicationLoggerInitializer
|
||||
@@ -8,7 +8,7 @@
|
||||
2. 注意修改 <property name="${log-path}/log.path" value=""/> 的value模块
|
||||
-->
|
||||
<configuration debug="false" scan="false">
|
||||
<property name="log.path" value="logs/pigx-upms"/>
|
||||
<property name="log.path" value="logs/${project.artifactId}"/>
|
||||
<!-- 彩色日志格式 -->
|
||||
<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}}"/>
|
||||
@@ -65,5 +65,6 @@
|
||||
<!-- Level: FATAL 0 ERROR 3 WARN 4 INFO 6 DEBUG 7 -->
|
||||
<root level="INFO">
|
||||
<appender-ref ref="console"/>
|
||||
<appender-ref ref="debug"/>
|
||||
</root>
|
||||
</configuration>
|
||||
Reference in new issue
Block a user