Exemplo n.º 1
0
        /// <summary>
        /// Creates a LoggingMgr instance using the configuration values referred to by the given config key
        /// into the LoggingConfigurations section of the app.config file
        /// </summary>
        /// <param name="loggingConfigKey">Key into LoggingConfigurations section to obtain settings</param>
        public LoggingMgr(string loggingConfigKey)
        {
            _loggingKey = loggingConfigKey;
            _configuredOptions.AppendFormat("LogKey: {0}{1}", loggingConfigKey, Environment.NewLine);
            LoggingConfiguration loggingConfigSection
                = AppConfigMgr.GetSection <LoggingConfiguration>(LoggingConfiguration.ConfigSectionName);
            LoggingElement loggingConfig = loggingConfigSection.GetLoggingConfig(loggingConfigKey);

            _backupFileLog = new FileLog(loggingConfig.BackupLogFileName
                                         , loggingConfig.BackupLogFileDirectory
                                         , enumEventPriority.All);
            _configuredTraceLevel = GetTraceLevelFromString(loggingConfig.TraceLevel);
            _configuredOptions.AppendFormat("BackupLogFile: {0}{1}", loggingConfig.BackupLogFileName, Environment.NewLine);
            _configuredOptions.AppendFormat("BackupLogFileDir: {0}{1}", loggingConfig.BackupLogFileDirectory, Environment.NewLine);
            InitLoggingTargets(
                BuildLoggingTargetsFromConfig(_backupFileLog, loggingConfig));
        }