Log4j2: Difference between revisions

From Chorke Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 3: Line 3:
<Configuration>
<Configuration>
     <Properties>
     <Properties>
         <Property name="finology.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.format">%d{MMM dd, yyyy HH:mm:ss a} %c [METHOD: %M , LINE: %L]%n[%-5p][%t] %m%n</Property>
         <Property name="finology.log.file.gz">${finology.log.dir}/%d{yyyyMM}/SPIDER-%d{yyyyMMdd}-%i.log.gz</Property>
         <Property name="academia.log.file.gz">${academia.log.dir}/%d{yyyyMM}/SPIDER-%d{yyyyMMdd}-%i.log.gz</Property>
         <Property name="finology.log.dir">${sys:user.home}/.shahed/finology/var/log/http</Property>
         <Property name="academia.log.dir">${sys:user.home}/.chorke/academia/var/log/http</Property>
         <Property name="finology.log.file">${finology.log.dir}/SPIDER.log</Property>
         <Property name="academia.log.file">${academia.log.dir}/SPIDER.log</Property>
     </Properties>
     </Properties>
     <Appenders>
     <Appenders>
         <RollingFile name="file" fileName="${finology.log.file}" filePattern="${finology.log.file.gz}" ignoreExceptions="false">
         <RollingFile name="file" fileName="${academia.log.file}" filePattern="${academia.log.file.gz}" ignoreExceptions="false">
             <PatternLayout pattern="${finology.log.format}"/>
             <PatternLayout pattern="${academia.log.format}"/>
             <Policies>
             <Policies>
                 <SizeBasedTriggeringPolicy size="10 MB"/>
                 <SizeBasedTriggeringPolicy size="10 MB"/>
Line 19: Line 19:
         </RollingFile>
         </RollingFile>
         <Console name="console" target="SYSTEM_OUT">
         <Console name="console" target="SYSTEM_OUT">
           <PatternLayout pattern="${finology.log.format}"/>
           <PatternLayout pattern="${academia.log.format}"/>
         </Console>
         </Console>
         <Async name="async">
         <Async name="async">
Line 27: Line 27:
     </Appenders>
     </Appenders>
     <Loggers>
     <Loggers>
         <Logger name="biz.shahed.finology.http.spider.mapper" level="warn"/>
         <Logger name="org.chorke.academia.http.spider.mapper" level="warn"/>
         <Logger name="springfox.documentation" level="warn"/>
         <Logger name="springfox.documentation" level="warn"/>
         <Logger name="edu.uci.ics.crawler4j" level="error"/>
         <Logger name="edu.uci.ics.crawler4j" level="error"/>
         <Logger name="org.apache.activemq" level="warn"/>
         <Logger name="org.apache.activemq" level="warn"/>
         <Logger name="biz.shahed.finology" level="info"/>
         <Logger name="org.chorke.academia" level="info"/>
         <Logger name="org.springframework" level="warn"/>
         <Logger name="org.springframework" level="warn"/>
         <Logger name="org.apache.camel" level="warn"/>
         <Logger name="org.apache.camel" level="warn"/>
Line 46: Line 46:
     </Loggers>
     </Loggers>
</Configuration>
</Configuration>
</source>
==Maven==
<source lang="xml">
<dependency>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-slf4j-impl</artifactId>
    <version>2.13.3</version>
</dependency>
</source>
</source>



Revision as of 03:19, 13 January 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>

Maven

<dependency>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-slf4j-impl</artifactId>
    <version>2.13.3</version>
</dependency>

References