header ads

Intellij에서 log4j2 설정하여 jar파일 만들기

IntelliJ에서 log4j2 설정하여 jar파일 만들기

1) 현상
 . Intellij에서 log4j2를 설정하여 Run하면 정상적으로 log4j2가 출력됨.
 . jar파일로 묶어서(Artifacts) Run하려고 하면 아래와 같은 오류메시지가 나옴.


ERROR StatusLogger No Log4j 2 configuration file found. Using default configuration (logging only errors to the console), or user programmatically provided configurations. Set system property 'log4j2.debug' to show Log4j 2 internal initialization logging. See https://logging.apache.org/log4j/2.x/manual/configuration.html for instructions on how to configure Log4j 2


 . 프로젝트 디렉토리 구조



 . 이때 Artifacts 생성하기전 jar 파일 구조를 보면 log4j2.xml이 빠져 있는 것이 보임.



  이 상태에서 Artifacts 로 jar파일을 만들어서 실행을 시키면


  압축된 jar 파일을 풀어서 보면 log4j2.xml이 빠져 있음이 보인다.


Intellij의 Project setting->Artifacts설정에서 log4j2.xml을 추가한다.



정상적으로 log4j2.xml을 읽어서 작동함.

jar 파일을 보면 log4j2.xml이 추가됨을 알 수 있음.

첨언
 - 왜 resource 폴더에 log4j2.xml이 있는데 자동으로 생성을 못해주는 걸까?
  













댓글 쓰기

0 댓글