'Log4j'에 해당되는 글 3건

  1. 2022.01.24 [Gradle] configurations 를 이용한 log4j dependency 반영
  2. 2021.08.02 [Log4J2] Executable Jar + Springboot framework 사용 예.
  3. 2012.06.22 Detected both log4j-over-slf4j.jar AND slf4j-log4j12.jar on the class path, preempting StackOverflowError.

[Gradle] configurations 를 이용한 log4j dependency 반영

ITWeb/개발일반 2022. 1. 24. 11:40

최근에 발생한 log4j 보안 이슈로 인해서 patch 작업이 필요 했었는데요.

build.gradle 에서 configurations 를 이용해서 쉽게 적용 할 수 있는 방법인데 기억하기 위해 이것도 기록해 봅니다.

 

관련 보안 내용은 아래 링크 참고 하시면 됩니다.

Log4j – Apache Log4j Security Vulnerabilities

 

Log4j – Apache Log4j Security Vulnerabilities

<!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You under the Apa

logging.apache.org

build.gradle)

configuration {
  all {
  	resolutionStrategy.eachDependency { DependencyResolveDetails details ->
    	if ( details.requested.group == 'org.apache.logging.log4j' ) {
        	details.useVersion '2.17.1'
        }
    }
  }
  
  compileOnly {
    extendsFrom annotationProccessor
  }
}

 

:

[Log4J2] Executable Jar + Springboot framework 사용 예.

ITWeb/개발일반 2021. 8. 2. 20:45

 

springboot framework 을 이용해서 executable jar 구현 시 log4j2 사용 예)
- @Slf4j 사용
- logback.xml 사용
- -Dlogback.configurationFile=$DIR_HOME/logback.xml

로그가 중복으로 남을 경우)
https://logging.apache.org/log4j/2.x/manual/configuration.html#Additivity
- <logger name="..." ... additivity="false" />
- 단순하게 보면, Logger 에 선언 된 appender 로 한번 기록하고 root logger 에 의해서 한번 기록 하게 되는 구조 입니다.

build.gradle 예)
configurations.all {
  exclude module: 'spring-boot-starter-logging'
}
...중략...
dependencies {
...중략...
  compile group: 'org.slf4j', name: 'slf4j-api', version: "${props.getProperty('slf4j')}"
  compile group: 'org.apache.logging.log4j', name: 'log4j-core', version: "${props.getProperty('log4j')}"
  compile group: 'ch.qos.logback', name: 'logback-classic', version: "${props.getProperty('logback')}"
  compile group: 'ch.qos.logback', name: 'logback-core', version: "${props.getProperty('logback')}"
...중략...
}

 

:

Detected both log4j-over-slf4j.jar AND slf4j-log4j12.jar on the class path, preempting StackOverflowError.

ITWeb/개발일반 2012. 6. 22. 09:41

[원본링크]


[내용발췌]

log4j-over-slf4j.jar and slf4j-logj12.jar cannot be present simultaneously

The presence of slf4j-logj12.jar, that is the log4j binding for SLF4J, will force all SLF4J calls to be delegated to log4j. The presence of log4j-over-slf4j.jar will in turn delegate all log4j API calls to their SLF4J equivalents. If both are present simultaneously, slf4j calls will be delegated to log4j, and log4j calls redirected to SLF4j, resulting in an endless loop.


팀에서 사용하고 있는 프로젝트 중에 저런 에러가 발생하길래 찾아본 내용입니다.

재밌는건 VM 장비상에서 어디서는 에러가 나고 어디서는 운좋게 에러가 안나고.. 참나.. 일관성 없다니까..

둘 중에 하나 삭제 하고 실행하면 잘 됩니다.


그냥 아쉬워서.. 그림 한장.. 추가요..



: