Logging
Always use a logging framework (GCG17001) 
Always use a well-established logging framework. They contain all necessary features. Additionally, they have been tested in practice and only contains a few bugs.
Exception: Small application, interactive console applications and scripts whose output does not need to be tracked, do not require a logging framework.
Define the usage of log levels (GCG17002) 
Suggestion:
| Log level | Description | Importance |
|---|---|---|
| Trace | The most fine-grained information only used in rare cases where you need the full visibility of what is happening in your application. Can be used to annotate each step in a complex algorithm. | Can be ignored during normal operations. A log level describing events showing step by step. |
| Debug | Less granular compared to Trace, but it is more than you will need in everyday use. Should be used for information that may be needed for diagnosis issues and troubleshooting or when running application in the test environment for purpose of making sure everything is running correctly |
Can be ignored during normal operations. A log level used for events considered to be useful during software debugging. |
| Info | The standard log level indicating that something happened, the application entered a certain state, etc. This log level should be purely informative and not looking into them on a regular basis shouldn't result in missing any important information. | Can be ignored during normal operations. An event happened, the event is purely informative. |
| Warn | The log level that indicates that something unexpected happened in the application, a problem, or a situation that might disturb one of the processes. That doesn't mean that the application failed. Should be used in situations that are unexpected, but the code can continue the work. | Unexpected behavior happened inside the application, but it is continuing its work, and the key business features are operating as expected. |
| Error | The log level that should be used when the application hits an issue preventing one or more functionalities from properly functioning. | One or more functionalities are not working, preventing some functionalities from working correctly. |
| Fatal, Critical | The log level that tells that the application encountered an event or entered a state in which one of the crucial business functionality is no longer working. May be used when the application is not able to connect to a crucial data store. Often the application is shutting down. | One or more key business functionalities are not working, and the whole system doesn't fulfill the business functionalities. |
Structured Logging (GCG17003) 
Structured logging1,2 helps to process log files.
Last update: 2021-09-26