Last active
October 12, 2016 03:27
-
-
Save kasundm5566/126a53d69839ac723fa1a39ddcf41771 to your computer and use it in GitHub Desktop.
log4j2 xml confiuration sample
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<Configuration> | |
<properties> | |
<!-- Format of the data written to log files. --> | |
<property name="format">%d{yyyy-MMM-dd HH:mm:ss:sss} %p [%t] %c %m%n</property> | |
<property name="log_root">/home/hsenid/Projects/myproject/modules/demo/logs</property> | |
</properties> | |
<Appenders> | |
<!-- Create a log file to hold info/warn log level details. --> | |
<RollingRandomAccessFile name="core-server-info-log" | |
fileName="${log_root}/core.server.info.log" | |
filePattern="${log_root}/demo.info.%d{yyyy-MM-dd}-%i.log"> | |
<PatternLayout> | |
<Pattern>${format}</Pattern> | |
</PatternLayout> | |
<Policies> | |
<!-- Roll over the file next day. --> | |
<TimeBasedTriggeringPolicy interval="1" modulate="true"/> | |
<!-- Maximum file size for the log file. Data will move to a new file after exceeding this limit. --> | |
<SizeBasedTriggeringPolicy size="2 MB"/> | |
</Policies> | |
<!-- Maximum number of files to keep. --> | |
<DefaultRolloverStrategy max="20"/> | |
<!-- Data of error/fatal log levels will be opted out when writing to the file. --> | |
<ThresholdFilter level="ERROR" onMatch="DENY" onMismatch="NEUTRAL"/> | |
</RollingRandomAccessFile> | |
<!-- Create a log file to hold error/fatal log level details. --> | |
<RollingRandomAccessFile name="core-server-error-log" | |
fileName="${log_root}/core.server.error.log" | |
filePattern="${log_root}/demo.info.%d{yyyy-MM-dd}-%i.log"> | |
<PatternLayout> | |
<Pattern>${format}</Pattern> | |
</PatternLayout> | |
<Policies> | |
<!-- Roll over the file next day. --> | |
<TimeBasedTriggeringPolicy interval="1" modulate="true"/> | |
<!-- Maximum file size for the log file. Data will move to a new file after exceeding this limit. --> | |
<SizeBasedTriggeringPolicy size="2 MB"/> | |
</Policies> | |
<!-- Maximum number of files to keep. --> | |
<DefaultRolloverStrategy max="20"/> | |
</RollingRandomAccessFile> | |
<!-- Standard console output. --> | |
<Console name="core-server-console-log" target="SYSTEM_OUT"> | |
<PatternLayout pattern="${format}"/> | |
</Console> | |
</Appenders> | |
<Loggers> | |
<Root level="info"> | |
<AppenderRef ref="core-server-info-log" level="info"/> | |
<AppenderRef ref="core-server-error-log" level="error"/> | |
<AppenderRef ref="core-server-console-log" level="info"/> | |
</Root> | |
</Loggers> | |
</Configuration> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment