Forráskód Böngészése

打印zillion的日志到单独文件

luoguangyi 2 éve
szülő
commit
cdb1f58429
2 módosított fájl, 16 hozzáadás és 7 törlés
  1. 6 0
      pom.xml
  2. 10 7
      src/main/resources/log4j.properties

+ 6 - 0
pom.xml

@@ -30,6 +30,7 @@
         <!--日志框架有安全漏洞,升级最新版本-->
         <logback.version>1.2.9</logback.version>
         <log4j2.version>2.17.0</log4j2.version>
+        <log4j.version>1.3.8.RELEASE</log4j.version>
         <xstream.version>1.4.18</xstream.version>
         <easyexcel.version>3.0.5</easyexcel.version>
 
@@ -75,6 +76,11 @@
             <artifactId>lombok</artifactId>
             <version>${lombok.version}</version>
         </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-log4j</artifactId>
+            <version>${log4j.version}</version>
+        </dependency>
         <!--		<dependency>-->
         <!--			<groupId>org.reflections</groupId>-->
         <!--			<artifactId>reflections</artifactId>-->

+ 10 - 7
src/main/resources/log4j.properties

@@ -1,16 +1,19 @@
-log4j.rootLogger=INFO,ConsoleAppender,RollingFileAppender
+log4j.rootLogger=INFO,ConsoleAppender,RollingLogFileAppender
 log4j.appender.RollingLogFileAppender=org.apache.log4j.RollingFileAppender
 log4j.appender.RollingLogFileAppender.Threshold=INFO
-log4j.appender.RollingLogFileAppender.ImmediateFlush=true
-log4j.appender.RollingLogFileAppender.File=zillion.log
+log4j.appender.RollingLogFileAppender.ImmediateFlush=false
+log4j.appender.RollingLogFileAppender.File=../logs/compute-engine/zillion.log
 log4j.appender.RollingLogFileAppender.Append=true
-log4j.appender.RollingLogFileAppender.MaxFileSize=128MB
-log4j.appender.RollingLogFileAppender.MaxBackupIndex=16
+log4j.appender.RollingLogFileAppender.MaxFileSize=20MB
+log4j.appender.RollingLogFileAppender.Encoding=UTF-8
+log4j.appender.RollingLogFileAppender.MaxBackupIndex=100
 log4j.appender.RollingLogFileAppender.layout=org.apache.log4j.PatternLayout
-log4j.appender.RollingLogFileAppender.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %t %m%n
+log4j.appender.RollingLogFileAppender.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss}:%-5p %l - %m%n
+#print Console
 log4j.appender.ConsoleAppender=org.apache.log4j.ConsoleAppender
 log4j.appender.ConsoleAppender.Threshold=INFO
 log4j.appender.ConsoleAppender.ImmediateFlush=true
 log4j.appender.ConsoleAppender.Target=System.out
 log4j.appender.ConsoleAppender.layout=org.apache.log4j.PatternLayout
-log4j.appender.ConsoleAppender.layout.ConversionPattern=%d{yyyy-MM-dd HH\:mm\:ss} %t %m%n
+log4j.appender.ConsoleAppender.Encoding=UTF-8
+log4j.appender.ConsoleAppender.layout.ConversionPattern=%d{yyyy-MM-dd HH\:mm\:ss} %m%n