public static void SetLoggerFunction(ILoggerCreator loggerFunc) { if (loggerFunc != null) { _loggerFunc = loggerFunc; } }
/// <summary> /// Load the class from the assembly /// </summary> /// <param name="className">The name of the class (namespace+class name)</param> /// <param name="assemblyName">The assembly that contain the class</param> /// <returns>An instance of ILoggerCreator</returns> private ILoggerCreator LoadAssembly(string className, string assemblyName) { ObjectHandle objectHandle = Activator.CreateInstance(assemblyName, className); ILoggerCreator loggerCreator = (ILoggerCreator)objectHandle.Unwrap(); loggerCreator.Configurate(); return(loggerCreator); }
/// <summary> /// Load the logger configuration from the app.config file, and create a ILoggerCreator object /// </summary> /// <returns>An object of ILoggerCreator</returns> private ILoggerCreator LoadConfiguration() { ILoggerCreator loggerCreator = null; try { LoggerSection loggerSection; // Gets the logger section from the default loggins loggerSection = (LoggerSection)ConfigurationManager.GetSection(LoggerSection.SectionName); if (loggerSection == null) { // Gets the logger from the framework app.condig file try { Configuration configuration = ConfigurationManager.OpenExeConfiguration(LoggingConstant.AppConfigName); loggerSection = (LoggerSection)configuration.GetSection(LoggerSection.SectionName); } catch (Exception ex) { throw new LoggingException("Unable to load logging configuration by using 'ConfigurationManager.OpenExeConfiguration(LoggingConstant.AppConfigName)'. Copy the content of the 'dk.gov.oiosi.logging.dll.config' into the default app.config/web.config file.", ex); } } if (loggerSection != null) { // The LoggerSection exist. // Try to create the defined logger. loggerCreator = this.LoadLoggerElement(loggerSection.LoggerElement); } else { throw new LoggingException("The logger section in the app.config file does not exist."); } } catch (LoggingException) { throw; } catch (Exception exception) { // Failed to create the loggerCreater defined in the app.config file. throw new LoggingException("Unable to create a logger base on the parameter in the app.Config file.", exception); } return(loggerCreator); }
/// <summary> /// Create a ILoggerCreator, that can create the desired logger, when needed /// </summary> /// <param name="loggerElement">The logger element, that contain the logger provider and configuration data</param> /// <returns>An object of ILoggerCreator</returns> private ILoggerCreator LoadLoggerElement(LoggerElement loggerElement) { ILoggerCreator loggerCreator = null; string[] parameters = loggerElement.Creator.Split(new string[] { ",", ";" }, StringSplitOptions.RemoveEmptyEntries); if (parameters.Length == 2) { // Try to load the logger dynamicly loggerCreator = this.LoadAssembly(parameters[0], parameters[1]); } else { // The numbers of parameter in the logger provider is not supported throw new LoggingException("Unable to create a logger base on the parameter '" + loggerElement.Creator + "'. The parameter must contain the classname and assambly name."); } return(loggerCreator); }
static LoggerFactory() { LoggerType = Type.GetType(Config.LogProvider, true); InitializeLoggerType(); Creator = DetermineLoggerCreator(); }
/// <summary> /// Private constructor /// </summary> private LoggerFactory() { loggerCreator = this.LoadConfiguration(); }
public static void SetLogger(ILoggerCreator loggerCreator) { LoggerFactory.SetLoggerFunction(loggerCreator); }
public OSPSuiteLogger(ILoggerCreator loggerCreator) { _loggerCreator = loggerCreator; }
public HomeController(ILoggerCreator loggerCreator) { _loggerCreator = loggerCreator; }
public TourController(ITourService tourService, ILoggerCreator loggerCreator) { _loggerCreator = loggerCreator; _tourService = tourService; }
public GuideController(IGuideService guideService, ILoggerCreator loggerCreator) { _loggerCreator = loggerCreator; _guideService = guideService; }
public TouristController(ITouristService touristServ, ILoggerCreator loggerCreator) { _loggerCreator = loggerCreator; _touristServ = touristServ; }