/// <summary> /// Get a logger, based on a String /// </summary> /// <param name="cat">the String that defines the log</param> /// <returns>a POILogger for the specified class</returns> public static POILogger GetLogger(String cat) { POILogger logger = null; // If we haven't found out what logger to use yet, // then do so now // Don't look it up until we're first asked, so // that our users can set the system property // between class loading and first use if (_loggerClassName == null) { try { _loggerClassName = "default"; //ConfigurationManager.AppSettings["loggername"]; } catch (Exception) {} // Use the default logger if none specified, // or none could be fetched if (_loggerClassName == null) { _loggerClassName = _nullLogger.GetType().Name; } } // Short circuit for the null logger, which // ignores all categories if (_loggerClassName.Equals(_nullLogger.GetType().Name)) { return(_nullLogger); } // Fetch the right logger for them, creating // it if that's required if (_loggers.ContainsKey(cat)) { logger = (POILogger)_loggers[cat]; } else { try { //logger=assembly.CreateInstance(_loggerClassName) as POILogger; Type loggerClass = Type.GetType(_loggerClassName); logger = Activator.CreateInstance(loggerClass) as POILogger; logger.Initialize(cat); } catch (Exception) { // Give up and use the null logger logger = _nullLogger; } // Save for next time _loggers[cat] = logger; } return(logger); }
public void Initialize(String cat) { this.logger = POILogFactory.GetLogger(cat); }
public override void Initialize(String cat) { this.logger = POILogFactory.GetLogger(cat); }