Log4j2: Difference between revisions
Jump to navigation
Jump to search
Line 106: | Line 106: | ||
==References== | ==References== | ||
* [https://stackoverflow.com/questions/24140359/ Conditional Property in <code>log4j2.xml</code>] | |||
* [https://stackoverflow.com/questions/36996935/ Log4j2 not writing to the RollingFile] | * [https://stackoverflow.com/questions/36996935/ Log4j2 not writing to the RollingFile] | ||
* [https://logging.apache.org/log4j/2.x/manual/configuration.html#PropertySubstitution Log4j2 Property Substitution] | * [https://logging.apache.org/log4j/2.x/manual/configuration.html#PropertySubstitution Log4j2 Property Substitution] | ||
* [https://logging.apache.org/log4j/2.x/manual/migration.html Log4j2 migrating from Log4j] | * [https://logging.apache.org/log4j/2.x/manual/migration.html Log4j2 migrating from Log4j] | ||
* [https://codecooks.com/log4j2-logging-framework/ Log4j2 Logging framework] | * [https://codecooks.com/log4j2-logging-framework/ Log4j2 Logging framework] | ||
* [https://logging.apache.org/log4j/2.x/manual/configuration.html Log4j2 Configuration] | * [https://logging.apache.org/log4j/2.x/manual/configuration.html Log4j2 Configuration] | ||
* [https://logging.apache.org/log4j/2.x/manual/cloud.html Using Log4j in Cloud Enabled Applications] |
Revision as of 07:41, 21 February 2021
<?xml version="1.0" encoding="UTF-8"?>
<Configuration>
<Properties>
<Property name="academia.log.format">%d{MMM dd, yyyy HH:mm:ss a} %c [METHOD: %M , LINE: %L]%n[%-5p][%t] %m%n</Property>
<Property name="academia.log.file.gz">${academia.log.dir}/%d{yyyyMM}/SPIDER-%d{yyyyMMdd}-%i.log.gz</Property>
<Property name="academia.log.dir">${sys:user.home}/.chorke/academia/var/log/http</Property>
<Property name="academia.log.file">${academia.log.dir}/SPIDER.log</Property>
</Properties>
<Appenders>
<RollingFile name="file" fileName="${academia.log.file}" filePattern="${academia.log.file.gz}" ignoreExceptions="false">
<PatternLayout pattern="${academia.log.format}"/>
<Policies>
<SizeBasedTriggeringPolicy size="10 MB"/>
<TimeBasedTriggeringPolicy interval="1"/>
<OnStartupTriggeringPolicy />
</Policies>
<DefaultRolloverStrategy max="20"/>
</RollingFile>
<Console name="console" target="SYSTEM_OUT">
<PatternLayout pattern="${academia.log.format}"/>
</Console>
<Async name="async">
<AppenderRef ref="file"/>
<AppenderRef ref="console"/>
</Async>
</Appenders>
<Loggers>
<Logger name="org.chorke.academia.http.spider.mapper" level="warn"/>
<Logger name="springfox.documentation" level="warn"/>
<Logger name="edu.uci.ics.crawler4j" level="error"/>
<Logger name="org.apache.activemq" level="warn"/>
<Logger name="org.chorke.academia" level="info"/>
<Logger name="org.springframework" level="warn"/>
<Logger name="org.apache.camel" level="warn"/>
<Logger name="org.thymeleaf" level="warn"/>
<Logger name="javax.servlet" level="warn"/>
<Logger name="bitronix.tm" level="warn"/>
<Logger name="org.jasypt" level="warn"/>
<Logger name="org.quartz" level="warn"/>
<Logger name="com.zaxxer" level="warn"/>
<Root level="info">
<AppenderRef ref="async"/>
</Root>
</Loggers>
</Configuration>
Disable
<?xml version="1.0" encoding="UTF-8"?>
<Configuration>
<Appenders>
<RollingFile name="file" fileName="${finology.log.file}" filePattern="${finology.log.file.gz}" ignoreExceptions="false">
<!-- skipped -->
</RollingFile>
<Console name="console" target="SYSTEM_OUT">
<!-- skipped -->
</Console>
<Async name="async">
<AppenderRef ref="file" level="info"/>
<AppenderRef ref="console" level="off"/>
</Async>
</Appenders>
<Loggers>
<!-- skipped -->
<Root level="info">
<AppenderRef ref="async"/>
</Root>
</Loggers>
</Configuration>
Maven
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>2.13.3</version>
</dependency>
System
<Property name="academia.log.dir">${sys:user.home}/.chorke/academia/var/log/http</Property>
Environment
#nano ~/.bashrc
#nano ~/.profile
export ACADEMIA_LOG_LEVEL_CLI="off"
export ACADEMIA_LOG_LEVEL_FILE="warn"
export ACADEMIA_WSS="$HOME/chorke/academia"
export ACADEMIA_LOG_PATH="$HOME/.chorke/academia/var/log/http"
sudo init 6
<Property name="academia.log.dir">${env:ACADEMIA_LOG_PATH}</Property>
<Property name="academia.log.level.cli">${env:ACADEMIA_LOG_LEVEL_CLI:-info}</Property>
<Property name="academia.log.level.file">${env:ACADEMIA_LOG_LEVEL_FILE:-warn}</Property>