-
Notifications
You must be signed in to change notification settings - Fork 357
Logging system
There is one simple rule: do not use System.out
or System.err
for any permanent logging
Of course we all do this temporarily during debugging, but it really shouldn't stay in the code. The logging infrastructure is quite easy to use. Just declare a static Logger
instance with an appropriate id (either package or logging topic) at the top of your class, and then use the Logger
API to create output:
...
import java.util.logging.Level;
import java.util.logging.Logger;
package x.y.z;
class MyClass .. {
static Logger log = JPF.getLogger("x.y.z");
...
log.severe("there was an error");
...
log.warning("there was a problem");
...
log.info("something FYI");
...
if (log.isLoggable(Level.FINE)){ // (1) don't create garbage
log.fine("this is some detailed info about: " + something);
}
...
}
Note that there is only one instance for each Logger
ID, i.e. you can have a corresponding static field in all your relevant classes, and don't have to share the fields. Another aspect that is mostly important for the lower log levels (e.g. FINE
) is that you should't concatenate log messages in operations that occur frequently, since the corresponding StringBuilder
instances can cause performance degradations even if the log level is not set (the arguments still get evaluated). In this case, encapsulate the logging in log.isLoggable(level){..}
blocks.
Please contact us by creating an issue. We are trying to fix the process below, which no longer works.
-
How to obtain and install JPF
- System requirements
- Downloading
- Creating a site properties file
- Building, testing, and running
- JPF plugins
-
Developer guide
- Top-level design
- Key mechanisms
- Extension mechanisms
- Common utilities
- Running JPF from within your application
- Writing JPF tests
- Coding conventions
- Hosting an Eclipse plugin update site