better test to check if logging has already been configured

This commit is contained in:
Doug MacEachern 2004-07-16 19:21:11 +00:00
parent dcdc74d06a
commit 661af074db
1 changed files with 8 additions and 1 deletions

View File

@ -18,9 +18,16 @@ public class SigarLog {
public static native void setLevel(Sigar sigar, int level);
private static boolean isLogConfigured() {
//funny, log4j has no api to determine if logging has been
//configured? .. yet bitches at you like a mo-fo when logging
//has not been configured.
return Logger.getRootLogger().getAllAppenders().hasMoreElements();
}
private static Logger getLogger() {
Logger log = Logger.getLogger("Sigar");
if (log.getLevel() == null) {
if (!isLogConfigured()) {
BasicConfigurator.configure();
}
return log;