Logging

๋กœ๊น…์ด๋ž€ ํ”„๋กœ๊ทธ๋žจ ์‹คํ–‰ ์ค‘์— ๋ฐœ์ƒํ•˜๋Š” ์˜ค๋ฅ˜์— ๋Œ€ํ•ด ๋””๋ฒ„๊น…ํ•˜๊ฑฐ๋‚˜ ์šด์˜ ์ค‘์ธ ํ”„๋กœ๊ทธ๋žจ์„ ๋ชจ๋‹ˆํ„ฐ๋ง ํ•˜๊ธฐ ์œ„ํ•ด ๋กœ๊ทธ๋ฅผ ๊ธฐ๋กํ•˜๋Š” ๊ฒƒ. ์ฝ˜์†”์— ์ถœ๋ ฅํ•˜๊ฑฐ๋‚˜ ํŒŒ์ผ ๋“ฑ์— ์ „๋‹ฌํ•˜์—ฌ ์ €์žฅํ•˜๋Š” ํ–‰์œ„

 

SLF4J

ํ’€ ๋„ค์ž„์€ Simple Logging Facade for Java (SLF4J) ๋ผ๋Š” ์ด๋ฆ„์—์„œ ์•Œ ์ˆ˜ ์žˆ๋“ฏ์ด ๋กœ๊น…์— ๋Œ€ํ•œ ์ถ”์ƒํ™”(์ธํ„ฐํŽ˜์ด์Šค) ์—ญํ• ์„ ํ•˜๋Š” ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ์ด๋‹ค. ์ด๋ฆ„์—์„œ๋ถ€ํ„ฐ Facade๊ฐ€ ๋“ค์–ด๊ฐ€์žˆ๋‹ค. ์ฆ‰, Facade๋ฅผ ํ†ตํ•ด์„œ ํด๋ผ์ด์–ธํŠธ ์ฝ”๋“œ์—์„œ๋Š” ์‹ค์ œ ๊ตฌํ˜„์„ ๋ชจ๋ฅด๊ณ  ๋กœ๊น… ํ”„๋ ˆ์ž„์›Œํฌ๋ฅผ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค. 

 

Facade Pattern

Facade๋Š” ๊ฑด์ถ•์—์„œ ๊ฑด๋ฌผ ์™ธ๊ด€์ด๋ผ๋Š” ๋œป์œผ๋กœ ์‚ฌ์šฉ๋˜๋Š” ์šฉ์–ด์ด๋‹ค. ์ด์™€๊ฐ™์ด ๋‚ด๋ถ€์ ์œผ๋กœ ๋ณต์žกํ•œ ์ฝ”๋“œ๋ฅผ ๊ฐ€์ ธ์ฃผ๋Š” ์ƒ์œ„ ์ˆ˜์ค€์˜ ์ธํ„ฐํŽ˜์ด์Šค ์—ญํ• ์„ ํ•˜๋Š” ๊ฐ์ฒด๊ฐ€ ์žˆ๋Š” ํŒจํ„ด์ด๋‹ค. 

 

์ด์™€ ๊ฐ™์ด ์ฝ”๋“œ ์ƒ์—์„œ๋„ ๋ณต์žกํ•œ ์„œ๋ธŒ์‹œ์Šคํ…œ์„ ์™ธ๋ถ€์—์„œ ๊ฐ์‹ธ๊ณ  ์žˆ๋Š” ๋Š๋‚Œ์ด๋‹ค. ๊ณ„์ขŒ๋ฅผ ๋ถ„์„ํ•ด์ฃผ๋Š” ๊ธฐ๋Šฅ์„ ๊ตฌํ˜„ํ•  ๋•Œ, ๋ฐ”๋กœ ๊ธฐ๋Šฅ์„ ๊ตฌํ˜„ํ•˜์ง€ ์•Š๊ณ , anylze()๋ผ๋Š” ๋ฉ”์†Œ๋“œ๋ฅผ ํ†ตํ•ด์„œ ์‹คํ–‰์„ ์‹œ์ผฐ์—ˆ๋‹ค. ์ด๋•Œ analyze๊ฐ€ ์ „๋ฉด์—์„œ ์ธํ„ฐํŽ˜์ด์Šค ์—ญํ• ์„ ํ•ด์ฃผ์—ˆ๋‹ค. ์‹ค์ œ analyze() ๋‚ด๋ถ€ ๋กœ์ง์—์„œ ํŒŒ์„œ๊ฐ€ ์‹คํ–‰๋˜๊ณ  ์œ ํšจ์„ฑ ๊ฒ€์‚ฌ ๋“ฑ์„ ํ•˜๋Š” ๋กœ์ง์ด ๋Œ์•„๊ฐ€๊ฒŒ ๋˜์—ˆ๋‹ค. 

์ด ํŒจํ„ด์„ ํ†ตํ•ด ๋ณต์žก์„ฑ์„ ์ค„์ด๊ณ  ์˜์กด์„ฑ์„ ๋‚ฎ์ถœ ์ˆ˜ ์žˆ๋‹ค. 

 

SLF4J์—์„œ ์‚ฌ์šฉ๋˜๋Š” Facade Pattern

SLF4J์—์„œ facade์—ญํ• ์„ ํ•˜๋Š” ์ธํ„ฐํŽ˜์ด์Šค๋Š” ๋ฌด์—‡์ผ๊นŒ? ๋ฐ”๋กœ logger ๊ฐ์ฒด์ด๋‹ค. ๊ทธ๋ž˜์„œ ๊ตฌํ˜„๋ถ€์— ์ƒ๊ด€์—†์ด logging ์ฒ˜๋ฆฌ๋ฅผ ํ•  ์ˆ˜ ์žˆ๋‹ค. ์‹ค์ œ๋กœ SLF4J๋Š” logback ๋“ฑ ํŒจํ‚ค์ง€ ์•ˆ์— ๋‹ค๋ฅธ ๋ชจ๋“ˆ์„ ํฌํ•จํ•˜๊ณ  ์žˆ๋‹ค.

 

class diagram์œผ๋กœ ๋ณธ ๊ฐœ๋…

Client ํด๋ž˜์Šค๋Š” Subsystem์ธ ํ•˜์œ„ ๊ฐ์ฒด์— ์ง์ ‘ ์ ‘๊ทผํ•˜์ง€ ์•Š๊ณ  Facade ๊ฐ์ฒด์—๋งŒ ์ ‘๊ทผํ•œ๋‹ค. Client๋Š” Facade ์ธํ„ฐํŽ˜์ด์Šค์—๋งŒ ์˜์กดํ•˜๊ณ  ๋ณต์žกํ•œ ํ•˜์œ„ ์‹œ์Šคํ…œ๊ณผ๋Š” ๋…๋ฆฝ์ ์ด๋‹ค.

 

 

 

seqeunce diagram์œผ๋กœ ๋ณธ ๊ฐœ๋…

์œ„ ์‹œํ€€์Šค ๋‹ค์ด์–ด๊ทธ๋žจ์„ ํ†ตํ•ด์„œ ๋Ÿฐํƒ€์ž„์‹œ Client ์™€ Facade์˜ ์ƒํ˜ธ์ž‘์šฉ์„ ๋ณผ ์ˆ˜ ์žˆ๋‹ค.

 

 

SLF4J ๋™์ž‘๊ณผ์ •

- SLF4J API๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋กœ๊น… ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ•œ๋‹ค

- ๋ฐฐํฌํ•  ๋•Œ, ๋ฐ”์ธ๋”ฉ ๋œ ๋กœ๊น… ํ”„๋ ˆ์ž„์›Œํฌ๊ฐ€ ์‹ค์ œ ๋กœ๊น… ์ฝ”๋“œ๋ฅผ ์ˆ˜ํ–‰ํ•œ๋‹ค.

 

 

 

์ฐธ๊ณ ์ž๋ฃŒ

 

Facade pattern - Wikipedia

From Wikipedia, the free encyclopedia Software design pattern The facade pattern (also spelled façade) is a software-design pattern commonly used in object-oriented programming. Analogous to a facade in architecture, a facade is an object that serves as a

en.wikipedia.org

 

 

SLF4J - Wikipedia

From Wikipedia, the free encyclopedia Simple Logging Facade for Java (SLF4J) provides a Java logging API by means of a simple facade pattern. The underlying logging backend is determined at runtime by adding the desired binding to the classpath and may be

en.wikipedia.org

 

'๐ŸงProgramming' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

Servlet  (0) 2024.01.19
Java๊ฐ€ ํŒŒ์ผ์„ ์ฝ๋„๋ก ํ•˜๋Š” ๋ฒ•  (0) 2024.01.14
React | export์™€ export default์˜ ์ฐจ์ด  (0) 2023.08.12
OCP  (0) 2022.02.21
Recoil | Selector  (0) 2021.12.01

+ Recent posts