Leonezhurui 2 лет назад
Родитель
Сommit
6d7f10fa00

+ 3 - 0
src/main/resources/application-dev.yaml

@@ -31,3 +31,6 @@ jwt:
   issuer: eai
   expiration: 86400
 
+
+logging:
+  config: classpath:log4j2-dev.xml

+ 3 - 5
src/main/resources/application-prod.yaml

@@ -19,11 +19,6 @@ spring:
     default-encoding: UTF-8
 
 
-logging:
-  file:
-    name: /app/logs/app.log
-
-
 # MyBatis配置
 mybatis-plus:
   mapper-locations: classpath:mapper/*.xml
@@ -36,3 +31,6 @@ jwt:
   issuer: eai
   expiration: 86400
 
+
+logging:
+  config: classpath:log4j2-prod.xml

+ 0 - 0
src/main/resources/log4j2-spring.xml → src/main/resources/log4j2-dev.xml


+ 22 - 0
src/main/resources/log4j2-prod.xml

@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Configuration>
+    <Properties>
+        <Property name="logPath">/app/logs</Property>
+        <Property name="logPattern">%style{%d{ISO8601}}{bright,green} %highlight{%-5level} [%style{%t}{bright,blue}] %style{%C{}}{bright,yellow}: %msg%n%style{%throwable}{red}</Property>
+    </Properties>
+    <Appenders>
+        <RollingFile name="RollingFile" fileName="${logPath}/app.log"
+                     filePattern="${logPath}/app-%d{yyyy-MM-dd}.log">
+            <PatternLayout pattern="${logPattern}" />
+            <Policies>
+                <TimeBasedTriggeringPolicy />
+            </Policies>
+            <DefaultRolloverStrategy max="14"/>
+        </RollingFile>
+    </Appenders>
+    <Loggers>
+        <Root level="info">
+            <AppenderRef ref="RollingFile" />
+        </Root>
+    </Loggers>
+</Configuration>