From 0f71bc844e4394cd2aabf79bc79240dc207ac006 Mon Sep 17 00:00:00 2001 From: erickson Date: Sun, 16 Dec 2007 20:00:28 +0000 Subject: [PATCH] parsing logfile settings and initing logger git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@1176 9efc2488-bf62-4759-914b-345cdb29e865 --- src/java/org/opensrf/Sys.java | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/java/org/opensrf/Sys.java b/src/java/org/opensrf/Sys.java index fd2fcc6..77cf4f7 100644 --- a/src/java/org/opensrf/Sys.java +++ b/src/java/org/opensrf/Sys.java @@ -9,6 +9,20 @@ import java.net.InetAddress; public class Sys { + private static void initLogger(Config config) { + if(Logger.instance() == null) { + try { + String logFile = config.getString("/logfile"); + int logLevel = config.getInt("/loglevel"); + Logger.init( (short) config.getInt("/loglevel"), new FileLogger(logFile)); + /** add syslog support... */ + } catch(Exception e) { + /* by default, log to stderr at WARN level */ + Logger.init(Logger.WARN, new Logger()); + } + } + } + /** * Connects to the OpenSRF network so that client sessions may communicate. * @param configFile The OpenSRF config file @@ -19,8 +33,6 @@ public class Sys { public static void bootstrapClient(String configFile, String configContext) throws ConfigException, SessionException { - if(Logger.instance() == null) /* provide a sane default logger */ - Logger.init(Logger.WARN, new Logger()); /** see if the current thread already has a connection */ XMPPSession existing = XMPPSession.getThreadSession(); @@ -32,6 +44,8 @@ public class Sys { config.parse(configFile); Config.setConfig(config); /* set this as the global config */ + initLogger(config); + /** Collect the network connection info from the config */ String username = config.getString("/username"); String passwd = config.getString("/passwd"); @@ -48,6 +62,7 @@ public class Sys { + "_t"+ Thread.currentThread().getId(); + try { /** Connect to the Jabber network */ -- 2.11.0