Adapters for migrating to the JDK 1.4 logging system.
This package is a partial backport of the JDK 1.4
logging system. If you want to migrate to the
JDK 1.4 logging system before being able to actually
run JDK 1.4, this package allows you to use the new
logging API without running the new JDK. When you
finally upgrade to JDK 1.4, you can simply
re-compile after chaning import statements.
For JDK 1.2 and 1.3:
import com.protomatter.syslog.util.logging.Logger;
import com.protomatter.syslog.util.logging.Level;
...
Logger logger = Logger.getLogger("logger-name");
logger.log(Level.WARNING, "warning message");
logger.log(Level.INFO, "info message");
logger.log(Level.CONFIG, "config message");
logger.severe("severe message");
logger.warning("warning message");
logger.info("info message");
|
You should get output in Syslog that looks like this:
05/04/2003 09:43:00 [WARN] [logger-name ] Test.main():59 warning message
05/04/2003 09:43:00 [INFO] [logger-name ] Test.main():60 info message
05/04/2003 09:43:00 [INFO] [logger-name ] Test.main():61 config message
05/04/2003 09:43:00 [EROR] [logger-name ] Test.main():58 severe message
05/04/2003 09:43:00 [WARN] [logger-name ] Test.main():59 warning message
05/04/2003 09:43:00 [INFO] [logger-name ] Test.main():60 info message
|
When you convert to JDK 1.4, change the import statements to:
import java.util.logging.Logger;
import java.util.logging.Level;
|
If you use the Syslog JDK 1.4 Handler implementation,
you can get identical output.
Note that if you use these classes, and don't have Syslog configured to compute
the caller class and method, then the caller name in your logs will be
incorrect. This is because the JDK 1.4 logging API doesn't have a mechanism
for directly getting a reference to the caller.
|