feat: add rolling-log-log4j2
This commit is contained in:
parent
a5c1e0688f
commit
985c1e7f0b
|
@ -29,19 +29,19 @@
|
|||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
<version>1.2.17</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-api</artifactId>
|
||||
<version>2.17.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>apache-log4j-extras</artifactId>
|
||||
<version>1.2.17</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-core</artifactId>
|
||||
<version>2.17.1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package de.swingbe.rollinglog;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
public class Main {
|
||||
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
<appender name="roll-by-size" class="org.apache.log4j.RollingFileAppender">
|
||||
|
||||
<!--define log file name-->
|
||||
<param name="file" value="target/log4j/roll-by-size/log.txt" />
|
||||
|
||||
<!--roll log file when size reaches threshold-->
|
||||
<param name="MaxFileSize" value="5KB" />
|
||||
|
||||
<!--keep number of log files within threshold-->
|
||||
<param name="MaxBackupIndex" value="20" />
|
||||
|
||||
<layout class="org.apache.log4j.PatternLayout">
|
||||
<param name="ConversionPattern" value="%d{yyyy-MM-dd HH:mm:ss} %-5p %m%n" />
|
||||
</layout>
|
||||
</appender>
|
|
@ -0,0 +1,13 @@
|
|||
<RollingFile
|
||||
name="rollingFile"
|
||||
fileName="${LOG_DIR}/log.txt"
|
||||
filePattern="${LOG_DIR}/log.%i.txt.gz"
|
||||
ignoreExceptions="false">
|
||||
<PatternLayout>
|
||||
<Pattern>%d{yyyy-MM-dd HH:mm:ss} %-5p %m%n</Pattern>
|
||||
</PatternLayout>
|
||||
<Policies>
|
||||
<SizeBasedTriggeringPolicy size="5KB" />
|
||||
</Policies>
|
||||
<DefaultRolloverStrategy max="5" />
|
||||
</RollingFile>
|
Loading…
Reference in New Issue