log4j.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration debug="false" xmlns:log4j='http://jakarta.apache.org/log4j/'>
<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{yyyy-MM-dd HH:mm:ss.SSS} %-5p [%t] %C{2}#%M (%F:%L) - %m%n" />
</layout>
</appender>
<appender name="FILE" class="org.apache.log4j.DailyRollingFileAppender">
<param name="append" value="true" />
<param name="encoding" value="UTF-8" />
<param name="file" value="logs/myapp/myapp.log" />
<param name="DatePattern" value="'.'yyyy-MM-dd" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{yyyy-MM-dd HH:mm:ss.SSS} %-5p [%t] %C{2}#%M (%F:%L) - %m%n" />
</layout>
</appender>
<logger name="_poligon" additivity="false">
<level value="debug" />
<appender-ref ref="CONSOLE" />
<appender-ref ref="FILE" />
</logger>
</log4j:configuration>
log4j2.xml:
<?xml version="1.0" encoding="UTF-8"?>
<Configuration monitorInterval="60">
<Properties>
<Property name="myapp.logs.dir">logs/myapp</Property>
<Property name="myapp.pattern.layout">%d{yyyy-MM-dd HH:mm:ss.SSS} %-5p [%t] %C{2}#%M (%F:%L) - %m%n
</Property>
<Property name="myapp.file.timepattern">%d{yyyy-MM-dd}</Property>
<Property name="myapp.file.name">myapp</Property>
</Properties>
<Appenders>
<Console name="CONSOLE" target="SYSTEM_OUT">
<PatternLayout pattern="${myapp.pattern.layout}" />
</Console>
<RollingFile name="FILE" fileName="${myapp.logs.dir}/${myapp.file.name}.log"
filePattern="${myapp.logs.dir}/${myapp.file.name}-${myapp.file.timepattern}.log.gz">
<PatternLayout pattern="${myapp.pattern.layout}" />
<Policies>
<TimeBasedTriggeringPolicy />
</Policies>
</RollingFile>
</Appenders>
<Loggers>
<Logger name="myapp" level="debug" additivity="false">
<AppenderRef ref="CONSOLE" />
<AppenderRef ref="FILE" />
</Logger>
</Loggers>
</Configuration>
Brak komentarzy:
Prześlij komentarz