Villemos / hbird-business

The business tier of the Open Ground Segment; Hummingbird
www.hbird.de
Apache License 2.0
2 stars 2 forks source link

Harmonization of logging #11

Open Villemos opened 11 years ago

Villemos commented 11 years ago

The logging should be harmonized;

  1. A common understanding of what is INFO; WARN and DEBUG.
  2. Creation of Logger, 'org.apache.log4j.Logger LOG = Logger.getLogger(X.class);' should be replaced with 'org.slf4j.Logger LOG = LoggerFactory.getLogger(X.class);'
  3. Log messages strings aggregated with '%s' or with " + ".
laurikimmel commented 11 years ago
  1. 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.

  2. OK. Using SLF4J is more flexibel and more convenient.
  3. 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());