[SPRING] Log4j2가 Spring 부트 로깅 구현을 찾을 수 없음
SPRINGLog4j2가 Spring 부트 로깅 구현을 찾을 수 없음
이 오류가 봄 부팅으로 log4j2를 사용하려고합니다.
ERROR StatusLogger Log4j2 could not find a logging implementation.
Please add log4j-core to the classpath. Using SimpleLogger to log to the console...
이 가이드를 따라갔습니다 : http://docs.spring.io/spring-boot/docs/current/reference/html/howto-logging.html#howto-configure-log4j-for-logging - 또한 https://logging.apache.org/log4j/2.x/maven-artifacts.html의 두 가지 log4j2 종속성
내 의존성 : 나무는 다음과 같이 보입니다.
[INFO] --- maven-dependency-plugin:2.10:tree (default-cli) @ musikkjulekalender ---
[INFO] no.saiboten:musikkjulekalender:war:1.0-SNAPSHOT
[INFO] +- org.springframework.boot:spring-boot-starter-web:jar:1.4.0.RELEASE:compile
[INFO] | +- org.hibernate:hibernate-validator:jar:5.2.4.Final:compile
[INFO] | | +- javax.validation:validation-api:jar:1.1.0.Final:compile
[INFO] | | +- org.jboss.logging:jboss-logging:jar:3.3.0.Final:compile
[INFO] | | \- com.fasterxml:classmate:jar:1.3.1:compile
[INFO] | +- org.springframework:spring-web:jar:4.3.2.RELEASE:compile
[INFO] | \- org.springframework:spring-webmvc:jar:4.3.2.RELEASE:compile
[INFO] +- org.springframework.boot:spring-boot-starter-jetty:jar:1.4.0.RELEASE:compile
[INFO] | +- org.eclipse.jetty:jetty-servlets:jar:9.3.11.v20160721:compile
[INFO] | | +- org.eclipse.jetty:jetty-continuation:jar:9.3.11.v20160721:compile
[INFO] | | +- org.eclipse.jetty:jetty-http:jar:9.3.11.v20160721:compile
[INFO] | | \- org.eclipse.jetty:jetty-io:jar:9.3.11.v20160721:compile
[INFO] | +- org.eclipse.jetty:jetty-webapp:jar:9.3.11.v20160721:compile
[INFO] | | +- org.eclipse.jetty:jetty-xml:jar:9.3.11.v20160721:compile
[INFO] | | \- org.eclipse.jetty:jetty-servlet:jar:9.3.11.v20160721:compile
[INFO] | | \- org.eclipse.jetty:jetty-security:jar:9.3.11.v20160721:compile
[INFO] | +- org.eclipse.jetty.websocket:websocket-server:jar:9.3.11.v20160721:compile
[INFO] | | +- org.eclipse.jetty.websocket:websocket-common:jar:9.3.11.v20160721:compile
[INFO] | | | \- org.eclipse.jetty.websocket:websocket-api:jar:9.3.11.v20160721:compile
[INFO] | | +- org.eclipse.jetty.websocket:websocket-client:jar:9.3.11.v20160721:compile
[INFO] | | \- org.eclipse.jetty.websocket:websocket-servlet:jar:9.3.11.v20160721:compile
[INFO] | \- org.eclipse.jetty.websocket:javax-websocket-server-impl:jar:9.3.11.v20160721:compile
[INFO] | +- org.eclipse.jetty:jetty-annotations:jar:9.3.11.v20160721:compile
[INFO] | | +- org.eclipse.jetty:jetty-plus:jar:9.3.11.v20160721:compile
[INFO] | | +- javax.annotation:javax.annotation-api:jar:1.2:compile
[INFO] | | +- org.ow2.asm:asm:jar:5.0.1:compile
[INFO] | | \- org.ow2.asm:asm-commons:jar:5.0.1:compile
[INFO] | | \- org.ow2.asm:asm-tree:jar:5.0.1:compile
[INFO] | +- org.eclipse.jetty.websocket:javax-websocket-client-impl:jar:9.3.11.v20160721:compile
[INFO] | \- javax.websocket:javax.websocket-api:jar:1.0:compile
[INFO] +- org.springframework.boot:spring-boot-starter-data-jpa:jar:1.4.0.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-aop:jar:1.4.0.RELEASE:compile
[INFO] | | \- org.aspectj:aspectjweaver:jar:1.8.9:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-jdbc:jar:1.4.0.RELEASE:compile
[INFO] | | +- org.apache.tomcat:tomcat-jdbc:jar:8.5.4:compile
[INFO] | | | \- org.apache.tomcat:tomcat-juli:jar:8.5.4:compile
[INFO] | | \- org.springframework:spring-jdbc:jar:4.3.2.RELEASE:compile
[INFO] | +- org.hibernate:hibernate-core:jar:5.0.9.Final:compile
[INFO] | | +- org.hibernate.javax.persistence:hibernate-jpa-2.1-api:jar:1.0.0.Final:compile
[INFO] | | +- org.javassist:javassist:jar:3.20.0-GA:compile
[INFO] | | +- antlr:antlr:jar:2.7.7:compile
[INFO] | | +- org.jboss:jandex:jar:2.0.0.Final:compile
[INFO] | | +- dom4j:dom4j:jar:1.6.1:compile
[INFO] | | | \- xml-apis:xml-apis:jar:1.4.01:compile
[INFO] | | \- org.hibernate.common:hibernate-commons-annotations:jar:5.0.1.Final:compile
[INFO] | +- org.hibernate:hibernate-entitymanager:jar:5.0.9.Final:compile
[INFO] | +- javax.transaction:javax.transaction-api:jar:1.2:compile
[INFO] | \- org.springframework:spring-aspects:jar:4.3.2.RELEASE:compile
[INFO] +- com.h2database:h2:jar:1.4.192:compile
[INFO] +- org.springframework.boot:spring-boot-starter-test:jar:1.4.0.RELEASE:test
[INFO] | +- org.springframework.boot:spring-boot-test:jar:1.4.0.RELEASE:test
[INFO] | +- org.springframework.boot:spring-boot-test-autoconfigure:jar:1.4.0.RELEASE:test
[INFO] | +- com.jayway.jsonpath:json-path:jar:2.2.0:test
[INFO] | | \- net.minidev:json-smart:jar:2.2.1:test
[INFO] | | \- net.minidev:accessors-smart:jar:1.1:test
[INFO] | +- org.assertj:assertj-core:jar:2.5.0:test
[INFO] | +- org.mockito:mockito-core:jar:1.10.19:test
[INFO] | | \- org.objenesis:objenesis:jar:2.1:test
[INFO] | +- org.hamcrest:hamcrest-core:jar:1.3:compile
[INFO] | +- org.hamcrest:hamcrest-library:jar:1.3:test
[INFO] | +- org.skyscreamer:jsonassert:jar:1.3.0:test
[INFO] | | \- org.json:json:jar:20140107:test
[INFO] | +- org.springframework:spring-core:jar:4.3.2.RELEASE:compile
[INFO] | \- org.springframework:spring-test:jar:4.3.2.RELEASE:test
[INFO] +- org.springframework.boot:spring-boot-starter:jar:1.4.0.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot:jar:1.4.0.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot-autoconfigure:jar:1.4.0.RELEASE:compile
[INFO] | \- org.yaml:snakeyaml:jar:1.17:runtime
[INFO] +- org.springframework.boot:spring-boot-starter-log4j2:jar:1.4.0.RELEASE:compile
[INFO] | +- org.apache.logging.log4j:log4j-slf4j-impl:jar:2.6.2:compile
[INFO] | +- org.slf4j:jcl-over-slf4j:jar:1.7.21:compile
[INFO] | \- org.slf4j:jul-to-slf4j:jar:1.7.21:compile
[INFO] +- org.apache.logging.log4j:log4j-api:jar:2.6.2:compile
[INFO] +- org.apache.logging.log4j:log4j-core:jar:2.6.2:compile
[INFO] +- org.apache.commons:commons-lang3:jar:3.3.2:compile
[INFO] +- org.mongodb:mongo-java-driver:jar:2.12.4:compile
[INFO] +- org.springframework.data:spring-data-mongodb:jar:1.9.2.RELEASE:compile
[INFO] | +- org.springframework:spring-tx:jar:4.3.2.RELEASE:compile
[INFO] | +- org.springframework:spring-context:jar:4.3.2.RELEASE:compile
[INFO] | +- org.springframework:spring-beans:jar:4.3.2.RELEASE:compile
[INFO] | +- org.springframework:spring-expression:jar:4.3.2.RELEASE:compile
[INFO] | +- org.springframework.data:spring-data-commons:jar:1.12.2.RELEASE:compile
[INFO] | \- org.slf4j:slf4j-api:jar:1.7.21:compile
[INFO] +- com.google.api-client:google-api-client:jar:1.18.0-rc:compile
[INFO] +- com.google.http-client:google-http-client-jackson2:jar:1.18.0-rc:compile
[INFO] | \- com.google.http-client:google-http-client:jar:1.18.0-rc:compile
[INFO] +- com.google.oauth-client:google-oauth-client:jar:1.18.0-rc:compile
[INFO] | \- com.google.code.findbugs:jsr305:jar:1.3.9:compile
[INFO] +- com.fasterxml.jackson.core:jackson-databind:jar:2.8.2:compile
[INFO] | \- com.fasterxml.jackson.core:jackson-annotations:jar:2.8.1:compile
[INFO] +- com.google.apis:google-api-services-oauth2:jar:v2-rev81-1.19.0:compile
[INFO] +- com.fasterxml.jackson.core:jackson-core:jar:2.8.2:compile
[INFO] +- org.mongodb.morphia:morphia:jar:0.107:compile
[INFO] +- org.springframework.security:spring-security-web:jar:4.1.1.RELEASE:compile
[INFO] | +- aopalliance:aopalliance:jar:1.0:compile
[INFO] | \- org.springframework.security:spring-security-core:jar:4.1.1.RELEASE:compile
[INFO] +- org.springframework.security:spring-security-config:jar:4.1.1.RELEASE:compile
[INFO] | \- org.springframework:spring-aop:jar:4.3.2.RELEASE:compile
[INFO] +- org.springframework.social:spring-social-config:jar:1.1.4.RELEASE:compile
[INFO] | \- org.springframework.social:spring-social-web:jar:1.1.4.RELEASE:compile
[INFO] | \- javax.inject:javax.inject:jar:1:compile
[INFO] +- org.springframework.social:spring-social-core:jar:1.1.4.RELEASE:compile
[INFO] +- org.springframework.social:spring-social-facebook:jar:2.0.3.RELEASE:compile
[INFO] +- org.apache.httpcomponents:httpclient:jar:4.3.6:compile
[INFO] | +- org.apache.httpcomponents:httpcore:jar:4.4.5:compile
[INFO] | \- commons-codec:commons-codec:jar:1.10:compile
[INFO] +- org.mockito:mockito-all:jar:1.10.8:compile
[INFO] +- junit:junit:jar:4.11:compile
[INFO] +- org.eclipse.jetty:apache-jsp:jar:9.3.11.v20160721:provided
[INFO] | +- org.eclipse.jetty:jetty-util:jar:9.3.11.v20160721:compile
[INFO] | +- org.eclipse.jetty:jetty-server:jar:9.3.11.v20160721:compile
[INFO] | +- org.eclipse.jetty.toolchain:jetty-schemas:jar:3.1:provided
[INFO] | +- javax.servlet:javax.servlet-api:jar:3.1.0:compile
[INFO] | +- org.mortbay.jasper:apache-jsp:jar:8.0.33:provided
[INFO] | | \- org.mortbay.jasper:apache-el:jar:8.0.33:provided
[INFO] | \- org.eclipse.jdt.core.compiler:ecj:jar:4.4.2:provided
[INFO] +- javax.servlet:jstl:jar:1.2:compile
[INFO] +- org.springframework.data:spring-data-jpa:jar:1.10.2.RELEASE:compile
[INFO] | +- org.springframework:spring-orm:jar:4.3.2.RELEASE:compile
[INFO] | \- org.aspectj:aspectjrt:jar:1.8.9:compile
[INFO] +- postgresql:postgresql:jar:9.1-901-1.jdbc4:compile
[INFO] \- joda-time:joda-time:jar:2.9.4:compile
표준 log4j2.xml 파일을 src / main / resources / config에 기본 config를 추가했습니다.
<?xml version="1.0" encoding="UTF-8"?>
<Configuration>
<Appenders>
<Console name="STDOUT" target="SYSTEM_OUT">
<PatternLayout pattern="%d %-5p [%t] %C{2} (%F:%L) - %m%n"/>
</Console>
</Appenders>
<Loggers>
<Logger name="org.apache.log4j.xml" level="info"/>
<Root level="debug">
<AppenderRef ref="STDOUT"/>
</Root>
</Loggers>
</Configuration>
어떤 추측인가? 나는 Spring Tool Suite와 Maven Spring-Boot Plugin 내에서 실행을 시도했다.
보편적 인 요청에 의해 다음은 완전한 pom.xml입니다.
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.0.RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>no.saiboten</groupId>
<artifactId>musikkjulekalender</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>Musikkjulekalender</name>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jetty</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<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.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j2</artifactId>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.6.2</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.6.2</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.3.2</version>
</dependency>
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongo-java-driver</artifactId>
<version>2.12.4</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb</artifactId>
</dependency>
<dependency>
<groupId>com.google.api-client</groupId>
<artifactId>google-api-client</artifactId>
<version>1.18.0-rc</version>
</dependency>
<dependency>
<groupId>com.google.http-client</groupId>
<artifactId>google-http-client-jackson2</artifactId>
<version>1.18.0-rc</version>
</dependency>
<dependency>
<groupId>com.google.oauth-client</groupId>
<artifactId>google-oauth-client</artifactId>
<version>1.18.0-rc</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.8.2</version>
</dependency>
<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-oauth2</artifactId>
<version>v2-rev81-1.19.0</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.8.2</version>
</dependency>
<dependency>
<groupId>org.mongodb.morphia</groupId>
<artifactId>morphia</artifactId>
<version>0.107</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.social</groupId>
<artifactId>spring-social-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.social</groupId>
<artifactId>spring-social-core</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.social</groupId>
<artifactId>spring-social-facebook</artifactId>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.3.6</version>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.10.8</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>apache-jsp</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.1-901-1.jdbc4</version>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.9.4</version>
</dependency>
</dependencies>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<useSystemClassLoader>false</useSystemClassLoader>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spring-releases</id>
<name>Spring Releases</name>
<url>https://repo.spring.io/libs-release</url>
</repository>
<repository>
<id>org.jboss.repository.releases</id>
<name>JBoss Maven Release Repository</name>
<url>https://repository.jboss.org/nexus/content/repositories/releases</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-releases</id>
<name>Spring Releases</name>
<url>https://repo.spring.io/libs-release</url>
</pluginRepository>
</pluginRepositories>
</project>
해결법
-
==============================
1.LogManager.class의 소스 코드를 찾아보고 log4j-core.jar / META-INF에있는 log4j-provider.properties에 LoggerContextFactory가 없다는 것을 알게되었습니다. 따라서 log4j-core.jar / META-INF / log4j-provider.properties 파일을 확인하거나 로컬 저장소에서 log4j-core.jar을 삭제할 수 있습니다.
LogManager.class의 소스 코드를 찾아보고 log4j-core.jar / META-INF에있는 log4j-provider.properties에 LoggerContextFactory가 없다는 것을 알게되었습니다. 따라서 log4j-core.jar / META-INF / log4j-provider.properties 파일을 확인하거나 로컬 저장소에서 log4j-core.jar을 삭제할 수 있습니다.
-
==============================
2.이 오류 메시지는 log4j-api 모듈이 해당 인터페이스의 구현을 찾거나로드 할 수 없을 때 생성됩니다. 보통 이것은 log4j-core 모듈이 classpath에서 빠져 있지만 의존성 그래프를 보지 않는다는 것을 의미합니다.
이 오류 메시지는 log4j-api 모듈이 해당 인터페이스의 구현을 찾거나로드 할 수 없을 때 생성됩니다. 보통 이것은 log4j-core 모듈이 classpath에서 빠져 있지만 의존성 그래프를 보지 않는다는 것을 의미합니다.
log4j-slf4j-impl 및 log4j-jul 모듈에는 일부 전이 종속성이 있지만 오류 메시지가 발생할 수 있다고 생각하지 않습니다.
더 자세히 조사 할 수있는 한 가지 방법은이 시스템 속성 집합 (-Dorg.apache.logging.log4j.simplelog.StatusLogger.level = TRACE)을 사용하여 응용 프로그램을 다시 시작하는 것입니다. 그러면 log4j 내부 디버그 로깅이 콘솔에 인쇄됩니다.
(일단 구성 파일이로드되면 Log4j2.xml 구성 파일의 시작 부분에
를 설정하여 StatusLogger 출력 레벨을 제어 할 수 있습니다. 그러나 구성 파일은 log4j-core 모듈에 의해로드되고 우리는 아직 안 ...) -
==============================
3.당신의 의존성이 올바른 것 같습니다. 이것은 로깅 프레임 워크로서 log4j2를 사용하는 spring-boot 응용 프로그램을 작동시키는 것입니다.
당신의 의존성이 올바른 것 같습니다. 이것은 로깅 프레임 워크로서 log4j2를 사용하는 spring-boot 응용 프로그램을 작동시키는 것입니다.
<!-- Spring logging --> <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.springframework.boot</groupId> <artifactId>spring-boot-starter-log4j2</artifactId> </dependency>
eclipse에서 실행하기위한 log4j2.xml을 리소스 폴더에 넣으십시오. 다른 디렉토리 (resource / conf)를 사용하기를 원한다면 다음과 같이 JVM 인자를 가진 log4j2 설정 경로를 제공하십시오 :
-Dlog4j.configurationFile = "conf / log4j2.xml"
포기하지 말고 logback에서 log4j2로 다시 전환하십시오 ...
-
==============================
4.여러 가지 이유가있을 수 있지만 일반적으로 잘못된 JAR (손상됨)이있을 수 있습니다. 저장소에서 JAR을 삭제하고 다시 다운로드하십시오. 문제를 해결할 것입니다.
여러 가지 이유가있을 수 있지만 일반적으로 잘못된 JAR (손상됨)이있을 수 있습니다. 저장소에서 JAR을 삭제하고 다시 다운로드하십시오. 문제를 해결할 것입니다.
제 경우에는 Maven 저장소에서 org 폴더를 삭제했습니다. {home} .m2 \ repository \ org.
나는 비슷한 질문을 게시했다. 스프링 부트 : ERROR StatusLogger Log4j2가 로깅 구현을 찾을 수 없습니다.
from https://stackoverflow.com/questions/39560740/log4j2-could-not-find-a-logging-implementation-with-sprint-boot by cc-by-sa and MIT license
'SPRING' 카테고리의 다른 글
[SPRING] 봄 MVC 최대 절전 모드 인코딩 / 다중 라인 가져 오기 SQL (0) | 2019.06.02 |
---|---|
[SPRING] utym8 charset과 Thymeleaf (0) | 2019.06.01 |
[SPRING] 봄 부팅 - JS를 웹 페이지에 추가 할 수 없음 (0) | 2019.05.31 |
[SPRING] 빈의 스프링 정적 초기화 (0) | 2019.05.31 |
[SPRING] AJAX 요청에 대한 응답으로 Spring MVC 컨트롤러에서 객체를 반환하는 방법은 무엇입니까? (0) | 2019.05.31 |