Skip to content

Logging Best Practices

Logging Best Practices

Logging best practice is to have the possibility to detect different events and situations in a software system. When such modules are installed, finding what is important could be completed even while the application is running and without stopping it.

Logging – On/Off Switch

It is a good practice to be able to disable the action tracing functionality for the time when everything is working perfectly. Sometimes this may boost the performance of the application. Many logging systems pass the values external channels and this increases the I/O operations.

DRY or not to DRY?

One of the ideas in programming is don’t repeat yourself. But too often it is good idea to implement yourself the basic interfaces for capsulation what you use beneath. This is one of the best practices of spring framework – coding with interfaces. This way you could swap an implementation of some library without the need to change the whole other application. This is called loose coupling.

Unfortunately there was a bug found in the log4j library, that if I correctly crafted message is passed it’s quickly to execution of uncontrolled executable file. If applications have an off switch – logging could be disabled until they are updated. If the usage is capsulated – the change may be in one place.

Having different level of logging, depending on the environment where the application is running. On Development environment – you’ll most likely want more details. On production – it is – sometimes a Privacy & Security Issue – so the logging is for more critical situations.

Most of the times the level of tracing is configured per installation basis. It is a rare to see a runtime updateable configuration of how much logging should an application execute.

It is a good idea to have time based log separation. Sometimes when nothing critical or significant has happened the system could delete the old works and clean up system storage.

It is considered generally a good idea to be able to trace the actions of an application through different channels and on different levels.

Images Used from

Leave a Reply

Your email address will not be published.