没有配置Log4j加载

时间:2016-06-26 08:32:26

标签: log4j log4j2

通过tomcat容器调用Log4j包装器api。我收到以下错误

 ERROR StatusLogger Unrecognized format specifier [d]
ERROR StatusLogger Unrecognized conversion specifier [d] starting at  position 16 in conversion pattern.
ERROR StatusLogger Unrecognized format specifier [thread]
ERROR StatusLogger Unrecognized conversion specifier [thread] starting at position 25 in conversion pattern.
ERROR StatusLogger Unrecognized format specifier [level]
ERROR StatusLogger Unrecognized conversion specifier [level] starting at position 35 in conversion pattern.
ERROR StatusLogger Unrecognized format specifier [logger]
ERROR StatusLogger Unrecognized conversion specifier [logger] starting at position 47 in conversion pattern.
ERROR StatusLogger Unrecognized format specifier [msg]
ERROR StatusLogger Unrecognized conversion specifier [msg] starting at position 54 in conversion pattern.
ERROR StatusLogger Unrecognized format specifier [n]
ERROR StatusLogger Unrecognized conversion specifier [n] starting at position 56 in conversion pattern.

SEVERE: Exception sending context initialized event to listener instance of class web.empire.erp.startup.ServerAccessor
java.lang.ExceptionInInitializerError
at empire.erp.server.subsystem.gateway.GatewayClient.logIn(GatewayClient.java:34)
at web.empire.erp.startup.ServerAccessor.contextInitialized(ServerAccessor.java:40)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4811)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5251)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1408)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1398)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)

Caused by: java.lang.NullPointerException: No Configuration was provided
at java.util.Objects.requireNonNull(Objects.java:228)
at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:477)
at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:561)
at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:577)
at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:212)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:242)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:45)
at org.apache.logging.log4j.LogManager.getContext(LogManager.java:174)
at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:618)
at empire.erp.server.commons.logging.LogHandler.<clinit>(LogHandler.java:17)
... 11 more

它没有说configFile丢失,所以这不是问题。似乎无法弄清楚什么是错的。以下是我的log4j2.xml

<?xml version="1.0" encoding="UTF-8"?>

<Configuration>

<Properties>
    <Property name="baseDir">c:\logs</Property>
</Properties>

<Appenders>
    <Console name="Console">
      <PatternLayout>
         <pattern>
            %d{yyyy-MM-dd HH:mm:ss.SSS} - %msg%n 
         </pattern>
      </PatternLayout>

    </Console>

    <RollingFile name="RollingFile" fileName="${baseDir}/app.log"  filePattern="${baseDir}/$${date:yyyy-MM}/app-%d{yyyy-MM-dd}.log.gz">
        <PatternLayout pattern="%d %p %c{1.} [%t] %m%n" />
        <CronTriggeringPolicy schedule="0 0 0 * * ?"/>
        <DefaultRolloverStrategy>
            <Delete basePath="${baseDir}" maxDepth="2">
            <IfFileName glob="*/app-*.log.gz" />
            <IfLastModified age="60d" />
            </Delete>
        </DefaultRolloverStrategy>
    </RollingFile>

</Appenders>    

<Loggers>

    <Logger name="EmpireLogger" level="info" additivity="false">
        <AppenderRef ref="Console" level="info"/>
        <AppenderRef ref="RollingFile" level="error"/>
    </Logger>

    <Root level="info">
      <AppenderRef ref="Console" level="info"/>
    </Root>
</Loggers>

</Configuration>


**EDIT**: classpath  
C:\Development\Tomcats\apache-tomcat-8.0.33\bin\bootstrap.jar;C:\Development\Hibernate\hibernate-release-5.1.0.Final\lib\required\hibernate-commons-annotations-5.0.1.Final.jar;C:\Development\Hibernate\hibernate-release-5.1.0.Final\lib\required\hibernate-core-5.1.0.Final.jar;C:\Development\Hibernate\hibernate-release-5.1.0.Final\lib\required\hibernate-jpa-2.1-api-1.0.0.Final.jar;C:\Development\Tomcats\apache-tomcat-8.0.33\bin\tomcat-juli.jar;C:\Program Files\Java\jdk1.8.0_92\lib\tools.jar;C:\Development\Hibernate\hibernate-release-5.1.0.Final\lib\required\antlr-2.7.7.jar;C:\Development\Hibernate\hibernate-release-5.1.0.Final\lib\required\classmate-1.3.0.jar;C:\Development\Hibernate\hibernate-release-5.1.0.Final\lib\required\dom4j-1.6.1.jar;C:\Development\Hibernate\hibernate-release-5.1.0.Final\lib\required\geronimo-jta_1.1_spec-1.1.1.jar;C:\Development\Hibernate\hibernate-release-5.1.0.Final\lib\required\jandex-2.0.0.Final.jar;C:\Development\Hibernate\hibernate-release-5.1.0.Final\lib\required\javassist-3.20.0-GA.jar;C:\Development\Hibernate\hibernate-release-5.1.0.Final\lib\required\jboss-logging-3.3.0.Final.jar;C:\Development\log4j2\apache-log4j-2.6-bin\log4j-api-2.6.jar;C:\Development\log4j2\apache-log4j-2.6-bin\log4j-core-2.6.jar;C:\Development\EclipseWorkSpaces\HomeDevWS\OptimalYou\bin

更新2 :更改配置标记中的stack = trace后的日志

ERROR StatusLogger Unrecognized format specifier [d]
ERROR StatusLogger Unrecognized conversion specifier [d] starting at position 16 in conversion pattern.
ERROR StatusLogger Unrecognized format specifier [thread]
ERROR StatusLogger Unrecognized conversion specifier [thread] starting at position 25 in conversion pattern.
ERROR StatusLogger Unrecognized format specifier [level]
ERROR StatusLogger Unrecognized conversion specifier [level] starting at position 35 in conversion pattern.
ERROR StatusLogger Unrecognized format specifier [logger]
ERROR StatusLogger Unrecognized conversion specifier [logger] starting at position 47 in conversion pattern.
ERROR StatusLogger Unrecognized format specifier [msg]
ERROR StatusLogger Unrecognized conversion specifier [msg] starting at position 54 in conversion pattern.
ERROR StatusLogger Unrecognized format specifier [n]
ERROR StatusLogger Unrecognized conversion specifier [n] starting at position 56 in conversion pattern.
Jul 03, 2016 5:28:31 PM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class web.empire.erp.startup.ServerAccessor
java.lang.ExceptionInInitializerError
at empire.erp.server.subsystem.gateway.GatewayClient.logIn(GatewayClient.java:34)
at web.empire.erp.startup.ServerAccessor.contextInitialized(ServerAccessor.java:39)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4811)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5251)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1408)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1398)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NullPointerException: No Configuration was provided
at java.util.Objects.requireNonNull(Objects.java:228)
at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:477)
at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:561)
at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:577)
at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:212)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:242)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:45)
at org.apache.logging.log4j.LogManager.getContext(LogManager.java:174)
at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:618)
at empire.erp.server.commons.logging.LogHandler.<clinit>(LogHandler.java:17)
... 11 more

0 个答案:

没有答案