Classes sending messages to the logger should create a static Logger object.
Calling the class method getLogger(String name) of the class Logger,
creates a Logger object. The parameter name should be a dot-separated name and should normally be based on the package name
The method logp(Level level,String sourceClass,String sourceMethod,String msg,Throwable thrown) Log a message,
specifying source class and method, with associated Throwable information.
The following example shows 2 code fragments of the class TestLogger.
This code fragment creates a Logger-object. The class is within the package 'com.test'
Beispiel:
static { logger = Logger.getLogger("com.test"); //Package is com.test } //The following code fragment sends a message //to the Logger-object try { String name = null; name.toString(); } catch (NullPointerException ex) { logger.logp(Level.WARNING,"test.TestLogger","test", "Objekt name ist null",ex); }