-
Notifications
You must be signed in to change notification settings - Fork 95
Logging
kasemir edited this page Apr 6, 2016
·
4 revisions
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.
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());
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);