运行log4j2 jar时发生错误

时间:2016-08-21 17:45:43

标签: intellij-idea jar log4j2

当您在intellij中运行项目时,会发生错误。只要我将项目收集到一个jar文件中并运行它,就会出错。

如果配置文件正确,可能是什么问题?

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 positi
    on 25 in conversion pattern.
    ERROR StatusLogger Unrecognized format specifier [level]
    ERROR StatusLogger Unrecognized conversion specifier [level] starting at positio
    n 35 in conversion pattern.
    ERROR StatusLogger Unrecognized format specifier [logger]
    ERROR StatusLogger Unrecognized conversion specifier [logger] starting at positi
    on 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.
    ERROR StatusLogger No log4j2 configuration file found. Using default configurati
    on: logging only errors to the console.
    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 positi
    on 25 in conversion pattern.
    ERROR StatusLogger Unrecognized format specifier [level]
    ERROR StatusLogger Unrecognized conversion specifier [level] starting at positio
    n 35 in conversion pattern.
    ERROR StatusLogger Unrecognized format specifier [logger]
    ERROR StatusLogger Unrecognized conversion specifier [logger] starting at positi
    on 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.
    %d [%thread] %-5level %logger - %msg%n

log4j2.xml

<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="ERROR">
    <Appenders>
        <Console name="Console" target="SYSTEM_OUT">
            <PatternLayout pattern="%d{dd-MM-yyyy HH:mm:ss} %p: %msg -- %l %n"/>
        </Console>
        <!-- Файловый аппендер -->
        <File name="file" fileName="d:\backup.log">
            <PatternLayout>
                <Pattern>%d{dd-MM-yyyy HH:mm:ss} [%-5p][%-20c{1}] [%-20M:%L] - %msg%n</Pattern>
            </PatternLayout>
        </File>
    </Appenders>
    <Loggers>
        <Root level="error">
            <AppenderRef ref="Console"/>
            <AppenderRef ref="file"/>
        </Root>
    </Loggers>
</Configuration>

1 个答案:

答案 0 :(得分:0)

错误更正版的apache-log4j-2.3 显然是在apache-log4j-2.6.2版本的bug中。