Open Villemos opened 11 years ago
My first vision of the logging levels
TRACE - message to help developer understand what happend in application. Entering method, value of the local variable, etc.
DEBUG - message to help understand what is happening in the application. Will not be actively watched. DEBUG messages help to track down issues when they are reported. Messages isolated in the application and not visible to outside unless you are looking the log files. Session created, commiting transaction, etc.
INFO - messages to help monitor the application. Can be used in realtime monitoring. Component starting / stopping, realtime monitoring stats, etc. INFO messages are suitable to publish to the out side from the application. For example using AMQ. Starting application, avg. throughput, starting nightly maintenence task, etc.
WARN - we know that something is going to fail soon. There is not mutch space left on the HDD. Network connection is down but no one is using it at the moment. User forgot the password - soon you have to handle password renewal ticket. Etc
ERROR - something is completly wrong. Someone has to take some action to fix the problem ASAP. Network is down and all my requests to web service are failing now.
FATAL - thats it - I'm going to hang up now! There is nothing else I can do. DB connection is down and I'm not able to reconnect even if DB is restarted at some point.
In cases of WARN and above it is good to include some advice or hint how to resolve the current problem. Contact firewall adminstrator, licence of product needs update, etc.
With SLF4J we can use simple placeholders. For example
LOG.debug("Session of the user {} is killed after {} seconds on inactivit", user.getUsername(), user.getIdleTime());
The logging should be harmonized;