header-img
Info :
728x90

Log4jdbc 

Log4j ๋ฅผ JDBC์™€ ์—ฐ๊ฒฐํ•˜์—ฌ ์‚ฌ์šฉํ•˜๊ธฐ ์œ„ํ•ด ๋งŒ๋“ค์–ด์ง„ ์˜คํ”ˆ์†Œ์Šค ํ”„๋กœ์ ํŠธ 

 

GitHub - arthurblake/log4jdbc: log4jdbc is a Java JDBC driver that can log SQL and/or JDBC calls (and optionally SQL timing info

log4jdbc is a Java JDBC driver that can log SQL and/or JDBC calls (and optionally SQL timing information) for other JDBC drivers using the Simple Logging Facade For Java (SLF4J) logging system. - G...

github.com

 

์œ„์˜ ์ฝ”๋“œ๋Š” origin ๋ฒ„์ „์ด๊ณ , ์˜ค๋ž˜๋˜์—ˆ๋‹ค..

์‹ฌ์ง€์–ด slf4j 2.0.7 ๋กœ ์ฝ”๋“œ ์—…๊ทธ๋ ˆ์ด๋“œ๋„ ์ง„ํ–‰๋˜์–ด ์žˆ๋‹ค.

 

Log4j ์™€ slf4j ๊ฐ€ ๋ญ”์ง€ ์•Œ์•„๋ณด๋„๋ก ํ•˜์ž. 

 

๋กœ๊น…(Logging)

์ปดํ“จํŒ…์—์„œ ๋กœ๊ทธํŒŒ์ผ์€ ์šด์˜ ์ฒด์ œ๋‚˜ ๋‹ค๋ฅธ ์†Œํ”„ํŠธ์›จ์–ด๊ฐ€ ์‹คํ–‰ ์ค‘์— ๋ฐœ์ƒํ•˜๋Š” ์ด๋ฒคํŠธ๋‚˜ ๊ฐ๊ธฐ ๋‹ค๋ฅธ ์‚ฌ์šฉ์ž์˜ ํ†ต์‹  ์†Œํ”„ํŠธ์›จ์–ด ๊ฐ„์˜ ๋ฉ”์„ธ์ง€๋ฅผ ๊ธฐ๋กํ•œ ํŒŒ์ผ์ด๋ฉฐ, ๋กœ๊ทธ๋ฅผ ๊ธฐ๋กํ•˜๋Š” ํ–‰์œ„๋ฅผ ๋กœ๊น…์ด๋ผ๊ณ  ํ•œ๋‹ค.

 

+) ๋กœ๊ทธ์˜ ์ข…๋ฅ˜๋กœ.. OS ๋‚ด ์‹œ์Šคํ…œ ๋กœ๊ทธ, FW ๋ฐฉํ™”๋ฒฝ ๋กœ๊ทธ, ์ธ์ฆ ๋กœ๊ทธ ๋“ฑ ์—ฌ๋Ÿฌ ๊ฐ€์ง€๊ฐ€ ์žˆ๋Š”๋ฐ Log4j์™€ slf4j๋Š” ํ”„๋กœ์ ํŠธ ๋‚ด์˜ ๋กœ๊ทธ, ์ฆ‰ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ๋กœ๊ทธ๋ฅผ ๋‹ค๋ฃจ๋Š” ๊ฒƒ.

 

Log4j (Log for Java)

๊ฐ€์žฅ ์˜ค๋ž˜๋œ ๋กœ๊น… ํ”„๋ ˆ์ž„์›Œํฌ. Apache์˜ Java ๊ธฐ๋ฐ˜ ๋กœ๊น… ํ”„๋ ˆ์ž„ ์›Œํฌ.
console ๋ฐ file ์ถœ๋ ฅ์˜ ํ˜•ํƒœ๋กœ logging์„ ๋„์™€์ฃผ๋ฉฐ, xml, properties๋กœ ํ™˜๊ฒฝ์„ ๊ตฌ์„ฑํ•  ์ˆ˜ ์žˆ์Œ.
* 2015๋…„ ๊ธฐ์ค€์œผ๋กœ ๊ฐœ๋ฐœ ์ค‘๋‹จ.

 

1. ์†๋„์™€ ์œ ์—ฐ์„ฑ์„ ๊ณ ๋ คํ•˜์—ฌ ๋””์ž์ธ. ์†๋„์— ์ตœ์ ํ™”๋˜์–ด ์žˆ์Œ.

2. ๋ฉ€ํ‹ฐ์Šค๋ ˆ๋“œ ํ™˜๊ฒฝ์—์„œ ์‚ฌ์šฉํ•ด๋„ ์•ˆ์ „

3. ๊ณ„์ธต์ ์ธ ๋กœ๊ทธ ์„ค์ •๊ณผ ์ฒ˜๋ฆฌ๋ฅผ ์ง€์›

4. ์ถœ๋ ฅ์„ ํŒŒ์ผ, ์ฝ˜์†”, java.io.OutputStream, java.io.Writer, TCP๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ์›๊ฒฉ ์„œ๋ฒ„, ์›๊ฒฉ Unix Syslog ๋ฐ๋ชฌ, ์›๊ฒฉ JMS ๊ตฌ๋…์ž, ์œˆ๋„์šฐNT EventLog๋กœ ๋ณด๋‚ผ ์ˆ˜ ์žˆ๊ณ , ์‹ฌ์ง€์–ด๋Š” E-mail๋กœ ๋ณด๋‚ด๊ธฐ๋„ ๊ฐ€๋Šฅ.

5. 6๊ณ„์ธต ํ˜•ํƒœ์˜ ๋กœ๊ทธ ๋ฉ”์„ธ์ง€ ๋ ˆ๋ฒจ์„ ์‚ฌ์šฉ

 

Log4j์˜ ๊ตฌ์„ฑ

Element Description
Logger ์ถœ๋ ฅํ•  ๋ฉ”์„ธ์ง€๋ฅผ Appender์—๊ฒŒ ์ „๋‹ฌ
Appender ์ „๋‹ฌ๋œ ๋กœ๊ทธ๋ฅผ ์–ด๋””์— ์ถœ๋ ฅํ•  ๊ฒƒ์ธ์ง€ ๊ฒฐ์ • (Console, File, JDBC ๋“ฑ)
Layout ๋กœ๊ทธ๋ฅผ ์–ด๋–ค ํ˜•์‹์œผ๋กœ ์ถœ๋ ฅํ•  ๊ฒƒ์ธ์ง€ ๊ฒฐ์ •

 

Log4j์˜ ๋กœ๊ทธ ๋ ˆ๋ฒจ

Log level Description
FATAL ์•„์ฃผ ์‹ฌ๊ฐํ•œ ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ•œ ์ƒํƒœ
ERROR ์š”์ฒญ์„ ์ฒ˜๋ฆฌํ•˜๋Š” ์ค‘ ๋ฌธ์ œ๊ฐ€ ๋ฐœ์ƒํ•œ ์ƒํƒœ
WARN ์‹คํ–‰์—๋Š” ๋ฌธ์ œ๊ฐ€ ์—†์ง€๋งŒ ํ–ฅํ›„ ์—๋Ÿฌ์˜ ์›์ธ์ด ๋  ์ˆ˜ ์žˆ๋Š” ๊ฒฝ๊ณ ์„ฑ ๋ฉ”์„ธ์ง€
INFO ์ƒํƒœ ๋ณ€๊ฒฝ๊ณผ ๊ฐ™์€ ์ •๋ณด์„ฑ ๋ฉ”์„ธ์ง€
DEBUG ๊ฐœ๋ฐœ ์‹œ ๋””๋ฒ„๊ทธ ์šฉ๋„๋กœ ์‚ฌ์šฉํ•˜๋Š” ๋ฉ”์„ธ์ง€
TRACE ๋””๋ฒ„๊ทธ ๋ ˆ๋ฒจ๋ณด๋‹ค ์ƒ์„ธํ•œ ์ด๋ฒคํŠธ๋ฅผ ๋‚˜ํƒ€๋‚ด๋Š” ๋ฉ”์„ธ์ง€

โ€ป FATAL > ERROR > WARN > INFO > DEBUG > TRAGE

 

slf4j(Simple Logging Facade for Java)

logger ์ถ”์ƒ์ฒด๋กœ์จ ๋‹ค๋ฅธ ๋กœ๊น… ํ”„๋ ˆ์ž„์›Œํฌ๊ฐ€ ์ ‘๊ทผํ•  ์ˆ˜ ์žˆ๋„๋ก ๋„์™€์ฃผ๋Š” ์ถ”์ƒํ™” ๊ณ„์ธต. (์ž์ฒด์ ์ธ ๋กœ๊น… ํ”„๋ ˆ์ž„์›Œํฌ๊ฐ€ ์•„๋‹˜)
์ฝ”๋“œ๋ฅผ ์ผ์ •ํ•˜๊ฒŒ ์œ ์ง€ํ•˜๋ฉด์„œ ๊ตฌํ˜„์ฒด์˜ ์ „ํ™˜์„ ํ†ตํ•ด ๋‹ค๋ฅธ ๋กœ๊น… ํ”„๋ ˆ์ž„์›Œํฌ๋กœ์˜ ์ „ํ™˜์„ ์‰ฝ๊ณ  ๊ฐ„๋‹จํ•˜๊ฒŒ ๊ฐ€๋Šฅํ•˜๊ฒŒ ํ•จ.

 

=> logback ์ด๋‚˜ log4jc์™€ ๊ฐ™์€ ๋กœ๊น… ํ”„๋ ˆ์ž„์›Œํฌ์˜ ์ธํ„ฐํŽ˜์ด์Šค ์—ญํ• .

 

log4j๋กœ ๊ตฌ์ถ•๋œ ํ”„๋กœ์ ํŠธ ๋กœ๊น…์„ logback ์œผ๋กœ ๋ฐ”๊ฟ€ ๋•Œ

- slf4j ๊ฐ€ ์—†๋‹ค๋ฉด ) logback ๋ฌธ๋ฒ•์œผ๋กœ ์ „๋ถ€ ์ปจ๋ฒ„ํŒ…ํ•ด์•ผํ•จ

- slf4j ๊ฐ€ ์žˆ๋‹ค๋ฉด ) ์ง€์ •๋œ ์˜์กด์„ฑ๋งŒ ๋ฐ”๊ฟ”์ฃผ๋ฉด ๋จ.

 

๊ทธ๋Ÿฌ๋ฏ€๋กœ, ๋กœ๊น… ํ”„๋กœ๊ทธ๋žจ์„ ๋„์ž…ํ•  ๋•Œ slf4j ๋ฅผ "๊ฐ™์ด" ๋„์ž…ํ•˜๋Š” ๊ฒƒ์„ ์ถ”์ฒœ.

 

log1jdb ์‚ฌ์šฉ ๋ฐฉ๋ฒ•

 

์‚ฌ์šฉ ๋ฐฉ๋ฒ•์€ ์•„๋ž˜์˜ ๋งํฌ. ๊ณต์‹ ํŽ˜์ด์ง€๋ฅผ ์ฐธ๊ณ ํ•˜๋„๋ก ํ•˜์ž.

maven ๊ธฐ๋ฐ˜์ด๋ƒ gradle ๊ธฐ๋ฐ˜์ด๋ƒ์— ๋”ฐ๋ฅธ ์…‹ํŒ…์ด ๋‹ค๋ฅด๊ธฐ ๋•Œ๋ฌธ.

 

 

Log4jdbc-log4j2

This project was imported from https://code.google.com/archive/p/log4jdbc-log4j2/ Original License: Apache License 2.0 log4jdbc-log4j2 is a modification of log4jdbc to natively use Log4j 2 (or SLF4J as usual), that supports JDBC 4.1 to JDBC 3, includes all

log4jdbc.brunorozendo.com

 

 

 

 

 

728x90
๋”๋ณด๊ธฐ
BACKEND/SpringBoot