zoukankan      html  css  js  c++  java
  • 附录1:spring slf4j log4j2的使用

    slf4j日志的抽象层,统一各个Log框架使用,地址:https://www.slf4j.org/

    log4j2,一个具体的日志实现框架,地址:https://logging.apache.org/log4j/2.x/

    在classpath的根目录下,maven项目的话resource就行新建一个log4j2.xml或者properties的配置文件,log4j2将会自动读取

    不管是不是web项目当然,slf4j的包肯定是要导入的。

    log4j2在非web项目下只需要导入

    <dependency>
                <groupId>org.apache.logging.log4j</groupId>
                <artifactId>log4j-api</artifactId>
                <version>2.11.0</version>
            </dependency>
            <dependency>
                <groupId>org.apache.logging.log4j</groupId>
                <artifactId>log4j-core</artifactId>
                <version>2.11.0</version>
            </dependency>

    如果是web项目的话需要导入

     <dependency>
                <groupId>org.apache.logging.log4j</groupId>
                <artifactId>log4j-web</artifactId>
                <version>2.11.0</version>
            </dependency>

    也是会自动读取log4j2.xml文件,Log4jServletContainerInitializer,log4j-web有一个类会自动设置,使用servlet3.0的特性当然也可以禁用,具体请参考官方文档,我觉得有时候默认也挺好。

  • 相关阅读:
    LeetCode 4 :Majority Element
    LeetCode 3 :Min Stack
    Oracle操作4
    plsql安装教程
    java Date与String互相转化
    Oracle操作3
    Oracle操作2
    Oracle操作
    Oracle11g修改密码
    Visual Studio2013完全卸载
  • 原文地址:https://www.cnblogs.com/xuzhen97/p/9330215.html
Copyright © 2011-2022 走看看