Skip to content
kasemir edited this page Apr 6, 2016 · 4 revisions

Logging

Log messages should be based on java.util.logging.

Earlier use of SLF4J, Log4J, Apache.commons.logging and others is deprecated. While they each may have some slight advantage, we do want to limit a spread of logging library dependencies.

Obtaining a Logger

Use a logger that reflects the plugin name, which typically is possible by using the package name of a class.

class MyClass
{
    final private static Logger logger = Logger.getLogger(getClass().getName());

Log Patterns

When encountering an exception, log the exception information which will result in a complete stack trace, including nested 'Caused by' exceptions:

catch (Exception ex)
{
    logger.log(Level.WARNING, "Something terrible happened", ex);

Clone this wiki locally