2017-12-30 21 views
0

intellij Ideaでmainメソッドを実行すると、プロジェクトにlog4j2があります。ログを出力するのに間違いありません。log4j2エラーStatusLogger認識できない変換指定子

私はそれがエラーを示しスタンドアロンアプリケーションとしてjarファイルへのmaven-シェードプラグインパッケージのプロジェクトを使用して、実行ジャー:コンソール出力

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. 
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. 

のpom.xmlの設定

java -cp package.jar com.xxx.TestMain

を。 log4j2.version = 2.10.0、春のブートバージョンが1.5.9.RELEASE

<dependencies> 
    <dependency> 
     <groupId>org.springframework.boot</groupId> 
     <artifactId>spring-boot-starter</artifactId> 
     <exclusions> 
      <exclusion> 
       <groupId>org.springframework.boot</groupId> 
       <artifactId>spring-boot-starter-logging</artifactId> 
      </exclusion> 
     </exclusions> 
    </dependency> 
    <dependency> 
     <groupId>org.slf4j</groupId> 
     <artifactId>slf4j-api</artifactId> 
     <version>1.7.25</version> 
    </dependency> 
    <dependency> 
     <groupId>org.apache.logging.log4j</groupId> 
     <artifactId>log4j-slf4j-impl</artifactId> 
     <version>${log4j2.version}</version> 
    </dependency> 
    <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-core</artifactId> 
     <version>${log4j2.version}</version> 
    </dependency> 
</dependencies> 
<build> 
    <plugins> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-shade-plugin</artifactId> 
      <version>3.1.0</version> 
      <configuration> 
       <createDependencyReducedPom>false</createDependencyReducedPom> 
      </configuration> 
      <executions> 
       <execution> 
        <phase>package</phase> 
        <goals> 
         <goal>shade</goal> 
        </goals> 
        <configuration> 
         <transformers> 
          <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer"> 
           <resource>META-INF/spring.handlers</resource> 
          </transformer> 
          <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer"> 
           <resource>META-INF/spring.schemas</resource> 
          </transformer> 
         </transformers> 
         <filters> 
          <filter> 
           <artifact>*:*</artifact> 
           <excludes> 
            <exclude>META-INF/*.SF</exclude> 
            <exclude>META-INF/*.DSA</exclude> 
            <exclude>META-INF/*.RSA</exclude> 
           </excludes> 
          </filter> 
         </filters> 
        </configuration> 
       </execution> 
      </executions> 
     </plugin> 
     <plugin> 
      <artifactId>maven-compiler-plugin</artifactId> 
      <configuration> 
       <source>1.8</source> 
       <target>1.8</target> 
      </configuration> 
     </plugin> 
    </plugins> 
    <resources> 
     <resource> 
      <directory>src/main/resources</directory> 
     </resource> 
    </resources> 
    <sourceDirectory>src/main/java</sourceDirectory> 
</build> 

log4j2.xmlコンフィグ

<?xml version="1.0" encoding="UTF-8"?> 
<Configuration status="debug" monitorInterval="30" shutdownHook="disable"> 
    <properties> 
     <property name="LOG_HOME">/data1/logs</property> 
     <property name="JOB_NAME">noname</property> 
    </properties> 
    <Appenders> 
     <Console name="Console" target="SYSTEM_OUT"> 
      <PatternLayout pattern="%date{yyyy-MM-dd HH:mm:ss} [%t] %level [%logger{36}][%file:%line] %msg%n%throwable"/> 
     </Console> 

     <RollingRandomAccessFile name="DetailFile" 
           fileName="${sys:LOG_HOME}/${sys:JOB_NAME}/detail.log" bufferedIO="false" 
           filePattern="${sys:LOG_HOME}/${sys:JOB_NAME}/detail.%d{yyyy-MM-dd}-%i.log"> 

      <PatternLayout 
        pattern="%date{yyyy-MM-dd HH:mm:ss} [%t] %level [%file:%line] %msg%n%throwable"/> 
      <Policies> 
       <TimeBasedTriggeringPolicy interval="1" modulate="true"/> 
       <SizeBasedTriggeringPolicy size="500 MB"/> 
      </Policies> 
     </RollingRandomAccessFile> 
     <RollingRandomAccessFile name="error" 
           fileName="${sys:LOG_HOME}/${sys:JOB_NAME}/error.log" bufferedIO="true" 
           filePattern="${sys:LOG_HOME}/${sys:JOB_NAME}/error.%d{yyyy-MM-dd}.log"> 

      <PatternLayout 
        pattern="%date{yyyy-MM-dd HH:mm:ss} [%t] %level [%logger{36}:%line] %msg%n%throwable"/> 
      <Policies> 
       <TimeBasedTriggeringPolicy interval="1" modulate="true"/> 
      </Policies> 
     </RollingRandomAccessFile> 
    </Appenders> 
    <Loggers> 
     <Root level="info"> 
      <AppenderRef ref="DetailFile"/> 
      <AppenderRef level="error" ref="error"/> 
     </Root> 
    </Loggers> 
</Configuration> 
+0

こちらから質問したいと思います。私は間違いを見ますが、疑問はありません。 – Ctznkane525

+0

このエラーを解決する方法を知りたい – corlydream

答えて

0

である私は、人々がLog4j2上の複数のバージョンを持っていたとき前にこのエラーを見てきましたクラスパス

+0

mavenパッケージログをチェックしましたが、Log4j2バージョンしかありません。 – corlydream

+0

あなたのアプリケーションからシステムプロパティ 'java.classpath'の値を出力してください。これは、一時的な依存関係またはその他の設定になります。 –

関連する問題