NutzCN Logo
问答 集成 log4j2 但是没有加载log4j2.xml
发布于 29天前 作者 wx_dc1uhcoqb670vfspa24d 179 次浏览 复制 上一个帖子 下一个帖子
标签: nutzwk
<dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-core</artifactId>
        <version>2.6</version>
    </dependency>
    <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-slf4j-impl</artifactId>
        <version>2.6</version>
    </dependency>
    <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-1.2-api</artifactId>
        <version>2.6</version>
    </dependency>
    <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-web</artifactId>
        <version>2.6</version>
    </dependency>
<?xml version="1.0" encoding="UTF-8"?>
<Configuration>
<Appenders>
<Console name="STDOUT" target="SYSTEM_OUT">
  <PatternLayout pattern="%d{HH:mm:ss.SSS} %-5p (%F:%L) %M - %m%n"/>
</Console>
</Appenders>
<Loggers>
<Root level="debug">
  <AppenderRef ref="STDOUT"/>
</Root>
</Loggers>
</Configuration>
/Users/dean/develop/apache-tomcat-8.5.16/bin/catalina.sh run
[2019-04-26 09:56:51,266] Artifact wk-web:war exploded: Waiting for server connection to start artifact deployment...
objc[14188]: Class JavaLaunchHelper is implemented in both /Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home/bin/java (0x10f9a44c0) and /Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home/jre/lib/libinstrument.dylib (0x10f9ed4e0). One of the two will be used. Which one is undefined.
Connected to the target VM, address: '127.0.0.1:62822', transport: 'socket'
26-Apr-2019 21:56:52.120 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Server version:        Apache Tomcat/8.5.16
26-Apr-2019 21:56:52.125 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Server built:          Jun 21 2017 17:01:09 UTC
26-Apr-2019 21:56:52.125 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Server number:         8.5.16.0
26-Apr-2019 21:56:52.125 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name:               Mac OS X
26-Apr-2019 21:56:52.125 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version:            10.14.1
26-Apr-2019 21:56:52.125 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture:          x86_64
26-Apr-2019 21:56:52.125 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home:             /Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home/jre
26-Apr-2019 21:56:52.125 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version:           1.8.0_121-b13
26-Apr-2019 21:56:52.125 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor:            Oracle Corporation
26-Apr-2019 21:56:52.125 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE:         /Users/dean/Library/Caches/IntelliJIdea2018.2/tomcat/Unnamed_wk-parent_4
26-Apr-2019 21:56:52.125 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME:         /Users/dean/develop/apache-tomcat-8.5.16
26-Apr-2019 21:56:52.127 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=/Users/dean/Library/Caches/IntelliJIdea2018.2/tomcat/Unnamed_wk-parent_4/conf/logging.properties
26-Apr-2019 21:56:52.128 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
26-Apr-2019 21:56:52.128 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:62822,suspend=y,server=n
26-Apr-2019 21:56:52.128 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -javaagent:/Users/dean/Library/Caches/IntelliJIdea2018.2/captureAgent/debugger-agent.jar=file:/private/var/folders/w8/jmdjjv417_7glsr0km6nck600000gn/T/capture115.props
26-Apr-2019 21:56:52.128 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dfile.encoding=utf-8
26-Apr-2019 21:56:52.128 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote=
26-Apr-2019 21:56:52.128 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.port=1044
26-Apr-2019 21:56:52.128 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.ssl=false
26-Apr-2019 21:56:52.128 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.authenticate=false
26-Apr-2019 21:56:52.129 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.rmi.server.hostname=127.0.0.1
26-Apr-2019 21:56:52.129 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djdk.tls.ephemeralDHKeySize=2048
26-Apr-2019 21:56:52.129 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.protocol.handler.pkgs=org.apache.catalina.webresources
26-Apr-2019 21:56:52.130 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=/Users/dean/Library/Caches/IntelliJIdea2018.2/tomcat/Unnamed_wk-parent_4
26-Apr-2019 21:56:52.130 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=/Users/dean/develop/apache-tomcat-8.5.16
26-Apr-2019 21:56:52.130 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=/Users/dean/develop/apache-tomcat-8.5.16/temp
26-Apr-2019 21:56:52.130 信息 [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [/Users/dean/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.]
26-Apr-2019 21:56:52.283 信息 [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-7777"]
26-Apr-2019 21:56:52.331 信息 [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
26-Apr-2019 21:56:52.334 信息 [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["ajp-nio-8009"]
26-Apr-2019 21:56:52.336 信息 [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
26-Apr-2019 21:56:52.336 信息 [main] org.apache.catalina.startup.Catalina.load Initialization processed in 559 ms
26-Apr-2019 21:56:52.411 信息 [main] org.apache.catalina.core.StandardService.startInternal Starting service [Catalina]
26-Apr-2019 21:56:52.411 信息 [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet Engine: Apache Tomcat/8.5.16
26-Apr-2019 21:56:52.421 信息 [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-7777"]
26-Apr-2019 21:56:52.445 信息 [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["ajp-nio-8009"]
26-Apr-2019 21:56:52.449 信息 [main] org.apache.catalina.startup.Catalina.start Server startup in 112 ms
Connected to server
[2019-04-26 09:56:52,871] Artifact wk-web:war exploded: Artifact is being deployed, please wait...
26-Apr-2019 21:57:00.234 信息 [RMI TCP Connection(2)-127.0.0.1] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/Users/dean/code_gf/GuanfuAPP_OMS_190301/wk-app/wk-web/target/GF-OMS/WEB-INF/lib/vcloud-sdk-java-1.0.0.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/Users/dean/code_gf/GuanfuAPP_OMS_190301/wk-app/wk-web/target/GF-OMS/WEB-INF/lib/log4j-slf4j-impl-2.6.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/Users/dean/code_gf/GuanfuAPP_OMS_190301/wk-app/wk-web/target/GF-OMS/WEB-INF/lib/slf4j-log4j12-1.7.21.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
 INFO [RMI TCP Connection(2)-127.0.0.1] - Starting Shiro environment initialization.
 INFO [RMI TCP Connection(2)-127.0.0.1] - An instance with name 'authc' already exists.  Redefining this object as a new instance of type cn.wizzer.app.web.commons.shiro.filter.PlatformAuthenticationFilter
 WARN [RMI TCP Connection(2)-127.0.0.1] - Statistics can no longer be enabled via configuration.
 INFO [RMI TCP Connection(2)-127.0.0.1] - Cache with name 'shiroDbRealm.authorizationCache' does not yet exist.  Creating now.
 INFO [RMI TCP Connection(2)-127.0.0.1] - Added EhCache named [shiroDbRealm.authorizationCache]
 INFO [RMI TCP Connection(2)-127.0.0.1] - Realms have been explicitly set on the SecurityManager instance - auto-setting of realms will not occur.
 INFO [RMI TCP Connection(2)-127.0.0.1] - Shiro environment initialized in 791 ms.
 INFO [RMI TCP Connection(2)-127.0.0.1] - NutFilter[nutz] starting ...
 INFO [RMI TCP Connection(2)-127.0.0.1] - Nutz Version : 1.r.67-20190109 
 INFO [RMI TCP Connection(2)-127.0.0.1] - Nutz.Mvc[nutz] is initializing ...
 INFO [RMI TCP Connection(2)-127.0.0.1] -  > scan 'cn.wizzer'
 

这个格式并不是配置的格式:
INFO [RMI TCP Connection(2)-127.0.0.1] -

private static final Log log = Logs.get();
这样获取的不是log4j2,而是Slf4j吧?

我觉得没有读取到这个log4j2.xml,因为删除了文件也是正常运行的。

2 回复

已经写得很清楚

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/Users/dean/code_gf/GuanfuAPP_OMS_190301/wk-app/wk-web/target/GF-OMS/WEB-INF/lib/vcloud-sdk-java-1.0.0.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/Users/dean/code_gf/GuanfuAPP_OMS_190301/wk-app/wk-web/target/GF-OMS/WEB-INF/lib/log4j-slf4j-impl-2.6.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/Users/dean/code_gf/GuanfuAPP_OMS_190301/wk-app/wk-web/target/GF-OMS/WEB-INF/lib/slf4j-log4j12-1.7.21.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]

添加回复
请先登陆
回到顶部