반응형
Log Level 에 대하여.
- Logging Level은 상황에 따라 필요한 로그를 보여주기 위해서 로그 정의할때 사용하는 level을 구분합니다.
- Logging level을 정의함으로써 얼마나 해당 정보가 crucial한지를 나타냅니다.
- 총 8단계로 구성되며, ALL < TRACE < DEBUG < INFO < WARN < ERROR < FATAL < OFF 순으로 구성되며, 대게 ALL OFF를 제외한 6단계를 사용합니다.
Logging level 정의
- ALL
- This log level logs any logging levels that are defined. It logs everything and includes custom logging levels as well. It is the combination of all other logging levels.
- TRACE
- The TRACE log level captures all the details about the behavior of the application. It is mostly diagnostic and is more granular and finer than DEBUG log level. This log level is used in situations where you need to see what happened in your application or what happened in the third-party libraries used. You can use the TRACE log level to query parameters in the code or interpret the algorithm’s steps.
- DEBUG
- With DEBUG, you are giving diagnostic information in a detailed manner. It is verbose and has more information than you would need when using the application. DEBUG logging level is used to fetch information needed to diagnose, troubleshoot, or test an application. This ensures a smooth running application.
- INFO
- INFO messages are like the normal behavior of applications. They state what happened. For example, if a particular service stopped or started or you added something to the database. These entries are nothing to worry about during usual operations. The information logged using the INFO log is usually informative, and it does not necessarily require you to follow up on it.
- WARN
- The WARN log level is used when you have detected an unexpected application problem. This means you are not quite sure whether the problem will recur or remain. You may not notice any harm to your application at this point. This issue is usually a situation that stops specific processes from running. Yet it does not mean that the application has been harmed. In fact, the code should continue to work as usual. You should eventually check these warnings just in case the problem reoccurs.
- ERROR
- Unlike the FATAL logging level, error does not mean your application is aborting. Instead, there is just an inability to access a service or a file. This ERROR shows a failure of something important in your application. This log level is used when a severe issue is stopping functions within the application from operating efficiently. Most of the time, the application will continue to run, but eventually, it will need to be addressed.
- FATAL
- FATAL means that the application is about to stop a serious problem or corruption from happening. The FATAL level of logging shows that the application’s situation is catastrophic, such that an important function is not working. For example, you can use FATAL log level if the application is unable to connect to the data store.
- OFF
- This log level does not log anything. This OFF level is used to turn off logging and is the greatest possible rank. With this log level, nothing gets logged at all.
Logging Library 활용
- 만약, INFO 수준까지의 로그를 보여주겠다고 한다면? INFO와 INFO보다 높은 순위인 레벨인 INFO, WARN, ERROR, FATAL, OFF의 로그를 모두 보여주게 됩니다.
- You can limit the information written to the log level by combining the log level with a logging framework.
- 로깅 정보를 이용하면 해당 정보가 얼마나 중요한지를 알 수 있어, 이에 대응하고 활용할 수 있습니다.
- searching for problems
- creating alerts
- troubleshooting
- checking the application.
- ease information search
- alerting
- filtering when handling vast log messages that the systems produce
- Logging Library
- C++: Boost::log, spdlog
- Java: Log4j
참고
- [Github] gabime/spdlog: https://github.com/gabime/spdlog
- log4j - Logging Levels(로그 레벨) 정리: https://m.blog.naver.com/PostView.naver?isHttpsRedirect=true&blogId=2zino&logNo=221641662104
- How to Choose Levels of Logging: https://www.section.io/engineering-education/how-to-choose-levels-of-logging/
- Boost::log: https://jeongbincom.tistory.com/91
반응형
'Study: ComputerScience(CS) > CS: Basic' 카테고리의 다른 글
[CS] 동시성와 병렬성 & 프로세스와 스레드 (1) | 2024.02.11 |
---|---|
[Web] 웹 브라우저에 URL을 입력하면 어떤 일이 생기나요? (feat. Amazon) (0) | 2022.07.19 |
[CS] 캐시(Cache)란? (0) | 2022.07.06 |
[CS] 링킹(Linking)에 대해 보다 심도있는 내용 (0) | 2022.07.05 |
[CS] 컴파일(Compile)에 대해 보다 심도있는 내용 (0) | 2022.07.05 |