====== Log4j2 ====== * Java 8 Lambda 지원 * [[https://logging.apache.org/log4j/2.x/manual/garbagefree.html|Garbage Free]]로 GC 를 최소화 했다. * 구현과 API를 분리했기 때문에 Slf4j 등으로 쉽게 이전 가능. ''java.util.Logging'', ''Commons logging'' 등과 쉽게 연동. ===== 취약점 ===== * [[https://www.slf4j.org/log4shell.html|Comments on the log4shell(CVE-2021-44228) vulnerability]] : 자세히 설명하고 있고 다른 logging 프레임워크들에대해서도 설명해줌 * [[https://www.boho.or.kr/data/secNoticeView.do?bulletin_writing_sequence=36389|Apache Log4j 2 보안 업데이트 권고]] * [[https://www.boannews.com/media/view.asp?idx=103443|[긴급] 로그4j 신규 취약점 ‘CVE-2021-45105’과 패치 ‘Log4j 2.17.0’ 나와]] * [[https://www.popit.kr/log4j-%eb%b3%b4%ec%95%88-%ec%b7%a8%ec%95%bd%ec%a0%90-%eb%8f%99%ec%9e%91%ec%9b%90%eb%a6%ac-%eb%b0%8f-jenkins-%ec%84%9c%eb%b2%84-%ed%99%95%ec%9d%b8-%eb%b0%a9%eb%b2%95/|log4j 보안 취약점 동작원리 및 jenkins 서버 확인 방법 | Popit]] * 최소한 ''2.17.0'' 이상 버전을 사용해야 한다. ===== 의존성 설정 ===== * [[https://logging.apache.org/log4j/2.0/runtime-dependencies.html|log4j 2 Runtime Dependencies]] * [[http://logging.apache.org/log4j/2.x/faq.html#which_jars|Log4j2 FAQ - Which JAR files do I need?]] dependencies { compile('com.example:example-project:1.0') { exclude group: 'log4j', module: 'log4j' exclude group: 'org.slf4j', module: 'slf4j-log4j12' } compile('org.apache.logging.log4j:log4j-core:2.11.2') compile('org.apache.logging.log4j:log4j-slf4j-impl:2.11.2') compile('org.apache.logging.log4j:log4j-1.2-api:2.11.2') } ===== Garbage Free 로 GC 최소화 ===== * [[http://www.rationaljava.com/2017/10/allocation-free-logging-with-log4j2.html|Rational Java: Allocation free logging with log4j2]] * [[https://logging.apache.org/log4j/2.x/manual/garbagefree.html|Garbage Free]] * Garbage Free 를 제대로 사용하려면 지원되는 로깅 패턴만 사용해야 한다. ===== Spring Boot with Lob4j 2 ===== *[[springframework:springboot|SpringBoot]] 와 함께 사용하기 * [[https://www.callicoder.com/spring-boot-log4j-2-example/|How to use Log4j 2 with Spring Boot]] ===== syslog ===== * [[linux:syslog|Linux syslog]] * [[https://www.baeldung.com/log4j-to-syslog|Writing Log Data to Syslog Using Log4j2 | Baeldung]] ===== log4jna ===== * https://github.com/dblock/log4jna * Log4JNA is a library of native appenders to write into WindowsTM Event Viewer for Log4j 2TM. ===== 참조 ===== * [[https://www.loggly.com/blog/benchmarking-java-logging-frameworks/|Benchmarking Java logging frameworks | Log Analysis | Log Monitoring by Loggly]] * ''Log4j2''의 ''File Appender'' + ''asynchronous logger'' 조합이 성능이 제일 좋다. * [[https://www.mkyong.com/logging/apache-log4j-2-tutorials/|Apache Log4j 2 Tutorials – Mkyong.com]] * [[https://howtodoinjava.com/log4j2/log4j-2-json-configuration-example/|Log4j 2 JSON Configuration Example - HowToDoInJava]] * [[https://www.baeldung.com/java-logging-ndc-log4j|Java Logging with Nested Diagnostic Context (NDC)]] * [[https://www.baeldung.com/log4j2-plugins|Log4j 2 Plugins | Baeldung]] * [[https://dzone.com/articles/spring-boot-log4j2-setup|Spring Boot Log4J2 Setup - DZone Java]]