-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
064e04a
commit 7763c33
Showing
12 changed files
with
168 additions
and
26 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
...e/ms-platform/ms-business/ms-user/src/main/java/com/zhonghuasheng/ms/UserApplication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,22 @@ | ||
package com.zhonghuasheng.ms; | ||
|
||
import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure; | ||
import org.springframework.beans.factory.config.YamlPropertiesFactoryBean; | ||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
import org.springframework.core.io.ClassPathResource; | ||
|
||
import java.util.Properties; | ||
|
||
@SpringBootApplication(exclude = {DruidDataSourceAutoConfigure.class}) | ||
public class UserApplication { | ||
|
||
public static void main(String[] args) { | ||
YamlPropertiesFactoryBean yaml = new YamlPropertiesFactoryBean(); | ||
yaml.setResources(new ClassPathResource("application.yml")); | ||
Properties property = yaml.getObject(); | ||
System.setProperty("SERVICE_NAME", property.getProperty("spring.application.name")); | ||
System.setProperty("FILE_PATH", property.getProperty("logging.file.path")); | ||
SpringApplication.run(UserApplication.class); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
musicstore-springboot-vue/ms-platform/ms-common/ms-log-spring-boot-starter/.gitignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.idea/ | ||
target | ||
*.iml | ||
../.idea/ |
30 changes: 30 additions & 0 deletions
30
musicstore-springboot-vue/ms-platform/ms-common/ms-log-spring-boot-starter/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<parent> | ||
<artifactId>ms-common</artifactId> | ||
<groupId>com.zhonghuasheng</groupId> | ||
<version>1.0-SNAPSHOT</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>ms-log-spring-boot-starter</artifactId> | ||
|
||
<properties> | ||
<maven.compiler.source>8</maven.compiler.source> | ||
<maven.compiler.target>8</maven.compiler.target> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-log4j2</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.lmax</groupId> | ||
<artifactId>disruptor</artifactId> | ||
<version>3.4.2</version> | ||
</dependency> | ||
</dependencies> | ||
</project> |
99 changes: 99 additions & 0 deletions
99
...vue/ms-platform/ms-common/ms-log-spring-boot-starter/src/main/resources/log4j2-spring.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!--monitorInterval:Log4j2 自动检测修改配置文件和重新配置本身,设置间隔秒数--> | ||
<configuration monitorInterval="5"> | ||
<!--日志级别以及优先级排序: OFF > FATAL > ERROR > WARN > INFO > DEBUG > TRACE > ALL --> | ||
<!--变量配置--> | ||
<Properties> | ||
<!-- 格式化输出: | ||
%date表示日期,%thread表示线程名, | ||
%-5level:级别从左显示5个字符宽度 | ||
%msg:日志消息,%n是换行符--> | ||
<!-- %logger{36} 表示 Logger 名字最长36个字符 --> | ||
<property name="LOG_PATTERN" value="[${sys:SERVICE_NAME}] [%date{yyyy-MM-dd HH:mm:ss.SSS}] [%thread] %-5level %logger{36} - %msg%n" /> | ||
<!-- 定义日志存储的路径,不要配置相对路径 --> | ||
<property name="FILE_PATH" value="${sys:FILE_PATH}/${sys:SERVICE_NAME}" /> | ||
<property name="FILE_NAME" value="${sys:SERVICE_NAME}" /> | ||
</Properties> | ||
|
||
<appenders> | ||
<console name="Console" target="SYSTEM_OUT"> | ||
<!--输出日志的格式--> | ||
<PatternLayout pattern="${LOG_PATTERN}"/> | ||
<!--控制台只输出level及其以上级别的信息(onMatch),其他的直接拒绝(onMismatch)--> | ||
<ThresholdFilter level="info" onMatch="ACCEPT" onMismatch="DENY"/> | ||
</console> | ||
|
||
<!--文件会打印出所有信息--> | ||
<!--<File name="Filelog" fileName="${FILE_PATH}/log4j2-all.log" append="true"> | ||
<PatternLayout pattern="${LOG_PATTERN}"/> | ||
</File>--> | ||
<RandomAccessFile name="Filelog" fileName="${FILE_PATH}/log4j2-all.log" append="true" immediateFlush="false"> | ||
<PatternLayout pattern="${LOG_PATTERN}"/> | ||
</RandomAccessFile> | ||
|
||
<!-- 这个会打印出所有的info及以下级别的信息,每次大小超过size,则这size大小的日志会自动存入按年份-月份建立的文件夹下面并进行压缩,作为存档--> | ||
<RollingFile name="RollingFileInfo" fileName="${FILE_PATH}/info.log" filePattern="${FILE_PATH}/${FILE_NAME}-INFO-%d{yyyy-MM-dd-HH}_%i.log.gz"> | ||
<!--控制台只输出level及以上级别的信息(onMatch),其他的直接拒绝(onMismatch)--> | ||
<ThresholdFilter level="info" onMatch="ACCEPT" onMismatch="DENY"/> | ||
<PatternLayout pattern="${LOG_PATTERN}"/> | ||
<Policies> | ||
<!--interval属性用来指定多久滚动一次,单位与RollingFile的filePattern一致,如果filePattern中配置的文件重命名规则是%d{yyyy-MM-dd HH-mm-ss}-%i,最小的时间粒度是ss,即秒钟。--> | ||
<TimeBasedTriggeringPolicy interval="1"/> | ||
<SizeBasedTriggeringPolicy size="100 MB"/> | ||
</Policies> | ||
<!-- DefaultRolloverStrategy同一文件夹下15个文件开始覆盖--> | ||
<DefaultRolloverStrategy max="15"/> | ||
</RollingFile> | ||
|
||
<!-- 这个会打印出所有的warn及以下级别的信息,每次大小超过size,则这size大小的日志会自动存入按年份-月份建立的文件夹下面并进行压缩,作为存档--> | ||
<RollingFile name="RollingFileWarn" fileName="${FILE_PATH}/warn.log" filePattern="${FILE_PATH}/${FILE_NAME}-WARN-%d{yyyy-MM-dd HH}_%i.log.gz"> | ||
<!--控制台只输出level及以上级别的信息(onMatch),其他的直接拒绝(onMismatch)--> | ||
<ThresholdFilter level="warn" onMatch="ACCEPT" onMismatch="DENY"/> | ||
<PatternLayout pattern="${LOG_PATTERN}"/> | ||
<Policies> | ||
<!--interval属性用来指定多久滚动一次,默认是1 hour--> | ||
<TimeBasedTriggeringPolicy interval="1"/> | ||
<SizeBasedTriggeringPolicy size="100 MB"/> | ||
</Policies> | ||
<!-- DefaultRolloverStrategy同一文件夹下15个文件开始覆盖--> | ||
<DefaultRolloverStrategy max="15"/> | ||
</RollingFile> | ||
|
||
<!-- 这个会打印出所有的error及以下级别的信息,每次大小超过size,则这size大小的日志会自动存入按年份-月份建立的文件夹下面并进行压缩,作为存档--> | ||
<RollingFile name="RollingFileError" fileName="${FILE_PATH}/error.log" filePattern="${FILE_PATH}/${FILE_NAME}-ERROR-%d{yyyy-MM-dd}_%i.log.gz"> | ||
<!--控制台只输出level及以上级别的信息(onMatch),其他的直接拒绝(onMismatch)--> | ||
<ThresholdFilter level="error" onMatch="ACCEPT" onMismatch="DENY"/> | ||
<PatternLayout pattern="${LOG_PATTERN}"/> | ||
<Policies> | ||
<!--interval属性用来指定多久滚动一次,默认是1 hour--> | ||
<TimeBasedTriggeringPolicy interval="1"/> | ||
<SizeBasedTriggeringPolicy size="100 MB"/> | ||
</Policies> | ||
<!-- DefaultRolloverStrategy同一文件夹下15个文件开始覆盖--> | ||
<DefaultRolloverStrategy max="15"/> | ||
</RollingFile> | ||
</appenders> | ||
|
||
<!--Logger节点用来单独指定日志的形式,比如要为指定包下的class指定不同的日志级别等。--> | ||
<!--然后定义loggers,只有定义了logger并引入的appender,appender才会生效--> | ||
<loggers> | ||
<!--使用AsyncLogger的异步日志方式--> | ||
<!--过滤掉spring和mybatis的一些无用的DEBUG信息--> | ||
<AsyncLogger name="org.mybatis" level="info" includeLocation="true"> | ||
<AppenderRef ref="Console"/> | ||
</AsyncLogger > | ||
<!--监控系统信息--> | ||
<!--若是additivity设为false,则 子Logger 只会在自己的appender里输出,而不会在 父Logger 的appender里输出。--> | ||
<AsyncLogger name="org.springframework" level="info" includeLocation="true"> | ||
<AppenderRef ref="Console"/> | ||
</AsyncLogger > | ||
|
||
<AsyncRoot level="info"> | ||
<appender-ref ref="Console"/> | ||
<appender-ref ref="Filelog"/> | ||
<appender-ref ref="RollingFileInfo"/> | ||
<appender-ref ref="RollingFileWarn"/> | ||
<appender-ref ref="RollingFileError"/> | ||
</AsyncRoot> | ||
</loggers> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
musicstore-springboot-vue/ms-platform/ms-config/src/main/resources/application.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
spring: | ||
profiles: | ||
active: dev | ||
active: dev |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters