2017-12-30 1 views
0

intellij 아이디어에서 main 메소드를 실행할 때 내 프로젝트에 log4j2가 있습니다. 로그가 올바르게 인쇄됩니다.log4j2 오류 StatusLogger 인식 할 수없는 변환 지정자

java -cp package.jar com.xxx.TestMain

콘솔 출력

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 설정 : 내가 파일을 항아리, 독립형 응용 프로그램으로 항아리를 실행 받는다는 - 그늘 플러그인 패키지 프로젝트를 사용할 때

는 오류 보여줍니다. 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 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.xml의 설정 classpath.

+0

maven 패키지 로그를 확인했는데 Log4j2 버전 만 있습니다. – corlydream

+0

응용 프로그램에서 시스템 속성'java.classpath'의 값을 출력하여 확인하십시오. 일시적인 종속성 또는 다른 구성 일 수 있습니다. –

관련 문제