logback config file
This commit is contained in:
parent
0b133f1896
commit
feb5f139c9
|
@ -0,0 +1,44 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration debug="true">
|
||||
|
||||
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<layout class="ch.qos.logback.classic.PatternLayout">
|
||||
<Pattern>
|
||||
%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n
|
||||
</Pattern>
|
||||
</layout>
|
||||
</appender>
|
||||
|
||||
<appender name="EMAIL" class="ch.qos.logback.classic.net.SMTPAppender">
|
||||
<smtpHost>smtp.mailgun.org</smtpHost>
|
||||
<smtpPort>25</smtpPort>
|
||||
<username>123</username>
|
||||
<password>123</password>
|
||||
<to>TO_EMAIL</to>
|
||||
<to>RO_ANOTHER_EMAIL</to>
|
||||
<from>FROM_EMAIL</from>
|
||||
<subject>TESTING: %logger{20} - %m</subject>
|
||||
|
||||
<layout class="ch.qos.logback.classic.html.HTMLLayout"/>
|
||||
|
||||
<cyclicBufferTracker class="ch.qos.logback.core.spi.CyclicBufferTracker">
|
||||
<!-- send just one log entry per email -->
|
||||
<bufferSize>1</bufferSize>
|
||||
</cyclicBufferTracker>
|
||||
|
||||
<!-- default asynchronousSending = true -->
|
||||
<!-- for single main() testing, turn off to avoid system exit without sending email-->
|
||||
<asynchronousSending>false</asynchronousSending>
|
||||
|
||||
</appender>
|
||||
|
||||
<logger name="com.mkyong" level="error" additivity="false">
|
||||
<appender-ref ref="EMAIL"/>
|
||||
</logger>
|
||||
|
||||
<root level="error">
|
||||
<appender-ref ref="CONSOLE"/>
|
||||
</root>
|
||||
|
||||
</configuration>
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration debug="true">
|
||||
|
||||
<property name="HOME_LOG" value="logs/app.log"/>
|
||||
|
||||
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<layout class="ch.qos.logback.classic.PatternLayout">
|
||||
<Pattern>
|
||||
%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n
|
||||
</Pattern>
|
||||
</layout>
|
||||
</appender>
|
||||
|
||||
<appender name="FILE-ROLLING" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${HOME_LOG}</file>
|
||||
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
|
||||
<fileNamePattern>logs/archived/app.%d{yyyy-MM-dd}.%i.log</fileNamePattern>
|
||||
<!-- each archived file, size max 10MB -->
|
||||
<maxFileSize>10MB</maxFileSize>
|
||||
<!-- total size of all archive files, if total size > 20GB, it will delete old archived file -->
|
||||
<totalSizeCap>20GB</totalSizeCap>
|
||||
<!-- 60 days to keep -->
|
||||
<maxHistory>60</maxHistory>
|
||||
</rollingPolicy>
|
||||
|
||||
<encoder>
|
||||
<pattern>%d %p %c{1.} [%t] %m%n</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<!-- https://logback.qos.ch/manual/appenders.html#AsyncAppender -->
|
||||
<!-- AsyncAppender will drop events of level TRACE, DEBUG and INFO if its queue is 80% full -->
|
||||
<appender name="ASYNC" class="ch.qos.logback.classic.AsyncAppender">
|
||||
<appender-ref ref="FILE-ROLLING" />
|
||||
<!-- defaulr 256 -->
|
||||
<queueSize>512</queueSize>
|
||||
</appender>
|
||||
|
||||
<logger name="com.mkyong" level="debug" additivity="false">
|
||||
<appender-ref ref="ASYNC"/>
|
||||
<appender-ref ref="CONSOLE"/>
|
||||
</logger>
|
||||
|
||||
<root level="error">
|
||||
<appender-ref ref="CONSOLE"/>
|
||||
</root>
|
||||
|
||||
</configuration>
|
||||
|
Loading…
Reference in New Issue