• log4j2j配置


    maven依赖

    <properties>
    <sl4j.version>1.7.7</sl4j.version>
    <log4j2.version>2.1</log4j2.version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
    <dependency>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-api</artifactId>
    <version>${log4j2.version}</version>
    </dependency>
    <dependency>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-1.2-api</artifactId>
    <version>${log4j2.version}</version>
    </dependency>
    <dependency>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-core</artifactId>
    <version>${log4j2.version}</version>
    </dependency>
    <dependency>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-slf4j-impl</artifactId>
    <version>${log4j2.version}</version>
    </dependency>

    配置:(只有trace模式下,才能打印出sql的结果集)
    <?xml version="1.0" encoding="UTF-8"?>
    <Configuration status="WARN" monitorInterval="60">

    <properties>
    <property name="logPath">${profiles.logpath}</property>
    </properties>

    <Appenders>

    <Console name="Console" target="SYSTEM_OUT">
    <PatternLayout pattern="[%X{hdsf.traceid}] [%X{hdsf.appid}] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %-5p %c:%L - %msg%n" />
    </Console>

    <RollingFile name="root" filename="${logPath}/runtine.log" filepattern="${logPath}/%d{yyyyMMdd}-%i-root.log">
    <PatternLayout pattern="[%X{hdsf.traceid}] [%X{hdsf.appid}] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %-5p %c:%L - %msg%n" />
    <Policies>
    <SizeBasedTriggeringPolicy size="100 MB"/>
    </Policies>
    <DefaultRolloverStrategy max="100"/>
    </RollingFile>

    </Appenders>


    <Loggers>

    <logger name="org.springframework.web.method.support" level="INFO"></logger>
    <logger name="org.springframework.context.event" level="INFO"></logger>
    <logger name="org.springframework.beans.factory.xml" level="INFO"></logger>
    <logger name="org.springframework.context.annotation" level="INFO"></logger>
    <logger name="org.springframework.web.servlet.resource" level="INFO"></logger>
    <logger name="org.apache.velocity" level="INFO"></logger>
    <logger name="org.springframework.beans" level="INFO"></logger>

    <logger name="org.springframework.core" level="INFO"></logger>
    <logger name="org.springframework.web" level="INFO"></logger>

    <logger name="org.apache.cxf" level="INFO"></logger>

    <Root level="trace">
    <AppenderRef ref="Console" />
    <AppenderRef ref="root" />
    </Root>

    </Loggers>
    </Configuration>
  • 相关阅读:
    Oracle常见故障问题
    java前后端加密(转载)
    美团在Redis上踩过的一些坑-3.redis内存占用飙升(转载)
    tomcat访问(access)日志配置、记录Post请求参数(转)
    angular2学习资源汇总
    Ionic2 常见问题及解决方案
    URL Schemes(转载)
    (四)文本编辑器Vim/Vi
    C#接口作用的深入理解
    C#连接SQL Server数据库进行简单操作
  • 原文地址:https://www.cnblogs.com/qiumingcheng/p/5864840.html
Copyright © 2020-2023  润新知