Logging

Which logging framework to use?

Pentaho has a variety of logging APIs currently in use. In the future all will be consolidated to SLF4J. For modifications to existing projects, use whatever is already in place. New development should use SLF4J.

What to log?

  • Errors: If the code detects an illegal state, log at the Error level before throwing an Exception.
  • Caught Exceptions: If an exception is caught from 3rd party code. Log it at the ERROR level with as much information as you can that doesn't expose sensitive data to the logs. If the code can recover from the exception it may attempt to do so (resort to fallback behavior, etc.), otherwise re-throw the Exception. This may result in multiple logging of the same events, but this can be suppressed later if desired.
  • Warnings: Log a warning if someone is calling deprecated code or deprecated arguments. Include what changes should be made to avoid the warning in the future. Anytime code resorts to fall-backs these should be logged at warn as well. This may help consumers diagnose configuration or integration issues.
  • Info: Log any information which may help developers or system administrators follow how the execution of a call is proceeding. Log important points in the execution of a call, when a certain path is taken vs another, etc. Class construction and method invocation are good points to log at INFO
  • Debug: Debug is the most verbose level of logging. If INFO logs at method invocation, DEBUG would be logging points within the method call.