public void EmitConfiguration(ILogConfig config)
        {
            // read the root folder for logs.
            _rootFolder = string.IsNullOrEmpty(config.Root) ? "logs" : config.Root;
            var rootPath = FileHelpers.GetAbsolutePath(_rootFolder);

            // make sure log root exists.
            if (!Directory.Exists(rootPath))
                Directory.CreateDirectory(rootPath);

            // loop through file log targets from the config
            foreach (var target in config.Targets)
            {
                if (!target.Enabled)
                    continue;

                switch (target.Type)
                {
                    case LogTargetType.File:
                        CreateFileLog(_mainConfig, target);
                        break;
                    case LogTargetType.Packet:
                        CreatePacketLog(_packetLoggerConfig, target);
                        break;
                }
            }

            if (config.Targets.Count(x => x.Type == LogTargetType.File) > 0) // if we have added new file loggers.
                Log.Logger = _mainConfig.CreateLogger(); // recreate the global logger.

            PacketLogger = _packetLoggerConfig.CreateLogger(); // create the packet logger too even if doesn't really contain any outputs.
        }
Beispiel #2
0
        public void SetUp()
        {
            string type = "RexToy.Logging.XmlLogConfig, RexToy.Common";

            _cfg1 = Reflector.LoadInstance <ILogConfig>(type, args: @"..\..\Logging\log1.xml");
            _cfg2 = Reflector.LoadInstance <ILogConfig>(type, args: @"..\..\Logging\log2.xml");
        }
Beispiel #3
0
        public ILog CreateLogger(string name, ILogConfig logConfig)
        {
            if (logConfig == null)
                return new Logger(name);

            return new Logger(name, logConfig);
        }
        /// <summary>
        /// Configures the agent logger.
        /// </summary>
        /// <param name="debug">
        /// A <see cref="bool"/>
        /// </param>
        /// <param name="config">
        /// A <see cref="ILogConfig"/>
        /// </param>
        /// <returns>
        /// A <see cref="ILogger"/>
        /// </returns>
        /// <remarks>This should only be called once, as soon as you have a valid config.</remarks>
        public static void ConfigureLogger(ILogConfig config)
        {
            CreateAuditLogLevel();

            var hierarchy = log4net.LogManager.GetRepository(Assembly.GetCallingAssembly()) as log4net.Repository.Hierarchy.Hierarchy;
            var logger    = hierarchy.Root;

            SetupLogLevel(logger, config);

            SetupFileLogAppender(logger, config);
            SetupAuditLogger(logger, config);
            SetupDebugLogAppender(logger);
            logger.RemoveAppender(TemporaryEventLogAppenderName);
            if (!config.Console)
            {
                logger.RemoveAppender(ConsoleLogAppenderName);
            }

            logger.Repository.Configured = true;

            // We have now bootstrapped the agent logger, so
            // remove the startup appender, then send its messages
            // to the agent logger, which will get picked up by
            // the other appenders.
            ShutdownStartupLogAppender(logger);

            Log.Initialize(new Logger());
        }
Beispiel #5
0
 internal static ILogConfig Single()
 {
     if (null == _single)
     {
         _single = new LogConfig();
     }
     return(_single);
 }
Beispiel #6
0
        public static void IsEnabledFor_finest_is_false_when_config_log_is_debug()
        {
            ILogConfig config = GetLogConfig("debug");

            LoggerBootstrapper.Initialize();
            LoggerBootstrapper.ConfigureLogger(config);
            Assert.IsFalse(Log.IsFinestEnabled);
        }
Beispiel #7
0
        public static void IsDebugEnabled_is_true_when_config_log_is_debug()
        {
            ILogConfig config = GetLogConfig("debug");

            LoggerBootstrapper.Initialize();
            LoggerBootstrapper.ConfigureLogger(config);
            Assert.That(Log.IsDebugEnabled);
        }
Beispiel #8
0
        public static void IsDebugEnabled_is_false_when_config_log_is_info()
        {
            ILogConfig config = GetLogConfig("info");

            LoggerBootstrapper.Initialize();
            LoggerBootstrapper.ConfigureLogger(config);
            Assert.IsFalse(Log.IsDebugEnabled);
        }
Beispiel #9
0
 private LogContext()
 {
     if (File.Exists(_path))
     {
         _cfg = new XmlLogConfig(_path);
     }
     _factory = new LoggerFactory();
 }
Beispiel #10
0
 internal void Initialize(ILogConfig logConfig)
 {
     ArgumentValidator.ThrowIfNull("logConfig", logConfig);
     this.config = logConfig;
     this.logSessionResetLockObject = new object();
     this.ResetLogSession();
     this.ReleaseLogInstance();
 }
Beispiel #11
0
        public ILog CreateLogger(string name, ILogConfig logConfig)
        {
            if (logConfig == null)
            {
                return(new Logger(name));
            }

            return(new Logger(name, logConfig));
        }
Beispiel #12
0
 public DataLogger(ILogConfig logConfig, IList <string> columnNames, IList <Type> columnTypes) : base(new List <string>
 {
     "LogSessionId",
     "LogSequenceNumber"
 }.Concat(columnNames).ToList <string>(), new List <Type>
 {
     typeof(string),
     typeof(string)
 }.Concat(columnTypes).ToList <Type>())
 {
     this.Initialize(logConfig);
 }
Beispiel #13
0
        /// <summary>
        /// Serializes the resource object from the specified message into either
        /// a byte array or a char array
        /// </summary>
        /// <param name="config">
        /// An ILogConfig reference
        /// </param>
        /// <param name="message">
        /// A LogMessage that contains the resource that must be serialized
        /// </param>
        /// <param name="resourceData">
        /// An object out parameter that will receive the serialized resource data. Typically
        /// this is either a Char array or Byte array depending on the prefered file storage.
        /// </param>
        /// <param name="resourceFileExtension">
        /// A string that will receive a proposed extensionname for the serialized resource data
        /// </param>
        /// <returns>
        /// A SerializedResourceDataType enum value that specifies the format of the serialized
        /// resource data.
        /// </returns>
        public static SerializedResourceDataType SerializeResource(
            ILogConfig config,
            LogMessage message,
            out object resourceData,
            out string resourceFileExtension)
        {
            // Determine type of resource
            switch (message.LogType)
            {
            case LogMessageType.Bytes:
                resourceData          = message.Bytes;
                resourceFileExtension = message.BytesExtension.CleanUpFileName().ToLower();
                return(SerializedResourceDataType.ByteArray);

            case LogMessageType.Exception:
                var formattedException = message.FormattedText;
                if (message.FormattedText == null)
                {
                    formattedException = config.FormattersException.Format(
                        message.LogLevel,
                        message.Exception,
                        message.FormatterName);
                }
                resourceData          = formattedException.Text.ToCharArray();
                resourceFileExtension = formattedException.Extension.CleanUpFileName().ToLower();
                return(SerializedResourceDataType.CharArray);

            case LogMessageType.Object:
                var formattedObject = message.FormattedText;
                if (message.FormattedText == null)
                {
                    formattedObject = config.FormattersObject.Format(
                        message.LogLevel,
                        message.Object,
                        message.FormatterName);
                }
                resourceData          = formattedObject.Text.ToCharArray();
                resourceFileExtension = formattedObject.Extension.CleanUpFileName().ToLower();
                return(SerializedResourceDataType.CharArray);

            case LogMessageType.Report:
                resourceData          = message.Report.ToCharArray();
                resourceFileExtension = message.ReportExtension.CleanUpFileName().ToLower();
                return(SerializedResourceDataType.CharArray);

            default:
                resourceData          = null;
                resourceFileExtension = null;
                return(SerializedResourceDataType.None);
            }
        }
        /// <summary>
        /// Setup the event log appender and attach it to a logger.
        /// </summary>
        /// <param name="logger">The logger you want to attach the event log appender to.</param>
        /// <param name="config">The configuration for the appender.</param>
        private static void SetupEventLogAppender(log4netLogger logger, ILogConfig config)
        {
#if NET45
            var appender = new EventLogAppender();
            appender.Layout          = eventLoggerLayout;
            appender.Name            = EventLogAppenderName;
            appender.LogName         = EventLogName;
            appender.ApplicationName = EventLogSourceName;
            appender.AddFilter(GetNoAuditFilter());
            appender.ActivateOptions();

            logger.AddAppender(appender);
#endif
        }
Beispiel #15
0
 public void Config(ILogConfig cfg)
 {
     if (cfg != null)
     {
         this._layout = cfg.Layout;
         this._writer = cfg.Writer;
         this._level = cfg.GetLogLevel(this._name);
     }
     else
     {
         this._layout = NullLayout.Instance;
         this._writer = NullWriter.Instance;
         this._level = LogLevel.None;
     }
 }
        //done
        private void CreateDataLogger(ILogConfig config)
        {
            _dataLoggerService = new DataLoggerService(config);
            _dataLoggerService.LoggingStarted += (sender, args) =>
            {
                _mainViewModel.GuiStatusViewModel.IsLogging     = true;
                _mainViewModel.GuiStatusViewModel.LoggingStatus = "Logging active!";
            };

            _dataLoggerService.LoggingStopped += (sender, args) =>
            {
                _mainViewModel.GuiStatusViewModel.IsLogging     = false;
                _mainViewModel.GuiStatusViewModel.LoggingStatus = "Logging stopped";
            };
        }
 private static FileAppender.LockingModelBase GetFileLockingModel(ILogConfig config)
 {
     if (config.FileLockingModelSpecified)
     {
         if (config.FileLockingModel.Equals(configurationLogFileLockingModel.minimal))
         {
             return((FileAppender.LockingModelBase) new FileAppender.MinimalLock());
         }
         else
         {
             return(new FileAppender.ExclusiveLock());
         }
     }
     return(new FileAppender.MinimalLock());
 }
Beispiel #18
0
 public void Config(ILogConfig cfg)
 {
     if (cfg != null)
     {
         this._layout = cfg.Layout;
         this._writer = cfg.Writer;
         this._level  = cfg.GetLogLevel(this._name);
     }
     else
     {
         this._layout = NullLayout.Instance;
         this._writer = NullWriter.Instance;
         this._level  = LogLevel.None;
     }
 }
Beispiel #19
0
 public LogWrapper(ILogConfig config, string[] columnNames)
 {
     ArgumentValidator.ThrowIfNull("config", config);
     ArgumentValidator.ThrowIfNull("config.SoftwareName", config.SoftwareName);
     ArgumentValidator.ThrowIfNull("config.SoftwareVersion", config.SoftwareVersion);
     ArgumentValidator.ThrowIfNull("config.ComponentName", config.ComponentName);
     ArgumentValidator.ThrowIfNull("config.LogType", config.LogType);
     ArgumentValidator.ThrowIfNull("config.LogPrefix", config.LogPrefix);
     ArgumentValidator.ThrowIfNull("config.LogPath", config.LogPath);
     ArgumentValidator.ThrowIfNull("columnNames", columnNames);
     this.inMemoryLogs = new Breadcrumbs <string>(64);
     this.logSchema    = new LogSchema(config.SoftwareName, config.SoftwareVersion, config.LogType, columnNames);
     this.log          = new Log(config.LogPrefix, new LogHeaderFormatter(this.logSchema), config.ComponentName);
     this.log.Configure(config.LogPath, config.MaxLogAge, (long)config.MaxLogDirectorySize, (long)config.MaxLogFileSize);
     this.isEnabled = config.IsLoggingEnabled;
 }
Beispiel #20
0
        /// <summary>
        /// Get (or create if one does not already exist) a logger
        /// matching the specification in the <code>LogConfig</code>
        /// provided
        /// </summary>
        /// <param name="logConfig_">The configuration specifying the properties of the logger required</param>
        /// <returns>An <code>ILogger</code> implementation</returns>
		public ILogger GetLogger(ILogConfig logConfig_)
		{
			lock (this)
			{
				ILogger logger;
				if (_loggers.TryGetValue(logConfig_.Name, out logger))
				{
					return logger;
				}

				// Need to create a new one
				logger = CreateLogger(logConfig_);
				_loggers.Add(logConfig_.Name, logger);

				return logger;
			}
		}
        /// <summary>
        /// Setup the file log appender and attach it to a logger.
        /// </summary>
        /// <param name="logger">The logger you want to attach the file appender to.</param>
        /// <param name="config">The configuration for the appender.</param>
        /// <exception cref="System.Exception">If an exception occurs, the Event Log Appender is setup
        /// to handle output.</exception>
        private static void SetupFileLogAppender(log4netLogger logger, ILogConfig config)
        {
            string logFileName = config.GetFullLogFileName();

            try
            {
                var appender = SetupRollingFileAppender(config, logFileName, "FileLog", FileLogLayout);
                appender.AddFilter(GetNoAuditFilter());
                appender.ActivateOptions();
                logger.AddAppender(appender);
            }
            catch (Exception)
            {
                // Fallback to the event logger if we cannot setup a file logger.
                SetupEventLogAppender(logger, config);
            }
        }
Beispiel #22
0
        // ******************************************************************
        // *																*
        // *					      Constructors	                        *
        // *																*
        // ******************************************************************

        /// <summary>
        /// Constructor
        /// </summary>
        public LogThread()
        {
            // Store arguments into members
            m_sessionGuid           = Guid.Empty;
            m_sessionConfig         = null;
            m_sessionFolderFullName = string.Empty;
            m_messageQueue          = new Queue <LogMessage>();
            m_monitorSyncRoot       = new object();
            m_streamers             = new Dictionary <string, ILogStreamer[]>(StringComparer.InvariantCultureIgnoreCase);
            m_isRunningFlag         = false;
            m_isWritingLogs         = 0;
            m_autoFlushTimer        = new System.Threading.Timer(
                new TimerCallback(OnAutoFlushTimer),
                null,
                Timeout.Infinite,
                Timeout.Infinite);
        }
Beispiel #23
0
		private ILogger CreateLogger(ILogConfig logConfig_)
		{
			if (LoggerType.Console.Equals(logConfig_.Type))
			{
				return CreateConsoleLogger(logConfig_);
			}

			if (LoggerType.Trace.Equals(logConfig_.Type))
			{
				return CreateTraceLogger(logConfig_);
			}

			if (LoggerType.File.EndsWith(logConfig_.Type))
			{
				return CreateFileLogger(logConfig_);
			}

			throw new ArgumentException("The specified type of logger can not be created", nameof(logConfig_));
		}
        // ******************************************************************
        // *																*
        // *					        Constructors                        *
        // *																*
        // ******************************************************************

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="sessionGuid">
        /// A Guid that uniquely indentifies the current logging session
        /// </param>
        /// <param name="sessionFolderFullName">
        /// A string that holds the current session folder (i.e. location where
        /// current log(s) will be persisted) including process context name
        /// </param>
        /// <param name="sessionResourceFolderFullName">
        /// A string that specifies the current session resource folder (i.e. location
        /// inside session folder where resource files will be persisted)
        /// </param>
        /// <param name="config">
        /// An ILogConfig reference to the configuration when the session was started
        /// </param>
        /// <param name="parameters">
        /// A Dictionary that holds parameters that were specified in the
        /// application configuration and associated with this streamer
        /// </param>
        /// <param name="logName">
        /// A string that specifies the log that is associated with this streamer
        /// </param>
        /// <param name="concurrentStreamersSameTypeCount">
        /// An integer that holds the number of streamer instances for this log that are of same
        /// class type. If this value equals <i>1</i>, there is only 1 streamer instance of this
        /// class type associated with the specified log.
        /// </param>
        /// <param name="concurrentStreamersSameTypeIndex">
        /// An integer that holds the specific index number of the streamer instance for this
        /// log for a specific class type. This property will only hold a value larger than zero
        /// when multiple streamers of same class type are associated to same log.
        /// </param>
        public LogStreamerInitArgs(
            Guid sessionGuid,
            string sessionFolderFullName,
            string sessionResourceFolderFullName,
            ILogConfig config,
            IParameterDictionary parameters,
            string logName,
            int concurrentStreamersSameTypeCount,
            int concurrentStreamersSameTypeIndex)
        {
            // Store agruments into members
            SessionGuid                   = sessionGuid;
            SessionFolderFullName         = sessionFolderFullName;
            SessionResourceFolderFullName = sessionResourceFolderFullName;
            SessionConfig                 = config;
            Parameters = parameters;
            LogName    = logName;
            ConcurrentStreamersSameTypeCount = concurrentStreamersSameTypeCount;
            ConcurrentStreamersSameTypeIndex = concurrentStreamersSameTypeIndex;
        }
        /// <summary>
        /// Setup the audit log file appender and attach it to a logger.
        /// </summary>
        /// <param name="logger">The logger you want to attach the audit log appender to.</param>
        /// <param name="config">The configuration for the appender.</param>
        private static void SetupAuditLogger(log4netLogger logger, ILogConfig config)
        {
            if (!config.IsAuditLogEnabled)
            {
                return;
            }

            string logFileName = config.GetFullLogFileName().Replace(".log", "_audit.log");

            try
            {
                var appender = SetupRollingFileAppender(config, logFileName, AuditLogAppenderName, AuditLogLayout);
                appender.AddFilter(GetAuditFilter());
                appender.AddFilter(new DenyAllFilter());
                appender.ActivateOptions();
                logger.AddAppender(appender);
            }
            catch (Exception)
            { }
        }
Beispiel #26
0
        // ******************************************************************
        // *																*
        // *					  ILogThread Interface                      *
        // *																*
        // ******************************************************************

        /// <summary>
        /// Starts the logger thread
        /// </summary>
        /// <param name="sessionGuid">
        /// A Guid that uniquely indentifies the current logging session
        /// </param>
        /// <param name="sessionFolderFullName">
        /// A string that holds the current session folder (i.e. location where
        /// current log(s) will be persisted) including process context name
        /// </param>
        /// <param name="sessionResourceFolderFullName">
        /// A string that specifies the current session resource folder (i.e. location
        /// inside session folder where resource files will be persisted)
        /// </param>
        /// <param name="config">
        /// An ILogConfig reference.<br/>
        /// Note: this instance wil be cloned to ensure that configuration changes after
        /// thread has been started will not affect current execution.
        /// </param>
        public virtual void Start(
            Guid sessionGuid,
            string sessionFolderFullName,
            string sessionResourceFolderFullName,
            ILogConfig config)
        {
            // Check if not already running
            if (m_isRunningFlag)
            {
                throw new InvalidOperationException("Cannot start a running LogThread");
            }

            // Turn running flag on
            m_isRunningFlag                 = true;
            m_sessionGuid                   = sessionGuid;
            m_sessionConfig                 = config.Clone();
            m_sessionFolderFullName         = sessionFolderFullName;
            m_sessionResourceFolderFullName = sessionResourceFolderFullName;

            // Ensure message queue is empty
            m_messageQueue.Clear();

            // Ensure cache of streamers is also empty
            m_streamers.Clear();

            // Create a new logging thread and start it
            m_thread = new Thread(new ThreadStart(StartThread))
            {
                Name = string.Format("Log Thread - {0}", sessionGuid)
            };
            m_thread.Start();

            // Start auto-flush timer?
            if (m_sessionConfig.AutoFlushStartupTime > 0 &&
                m_sessionConfig.AutoFlushPeriodicTime > 0)
            {
                m_autoFlushTimer.Change(
                    m_sessionConfig.AutoFlushStartupTime,
                    m_sessionConfig.AutoFlushPeriodicTime);
            }
        }
Beispiel #27
0
        public void EmitConfiguration(ILogConfig config)
        {
            // read the root folder for logs.
            _rootFolder = string.IsNullOrEmpty(config.Root) ? "logs" : config.Root;
            var rootPath = FileHelpers.GetAbsolutePath(_rootFolder);

            // make sure log root exists.
            if (!Directory.Exists(rootPath))
            {
                Directory.CreateDirectory(rootPath);
            }

            // loop through file log targets from the config
            foreach (var target in config.Targets)
            {
                if (!target.Enabled)
                {
                    continue;
                }

                switch (target.Type)
                {
                case LogTargetType.File:
                    CreateFileLog(_mainConfig, target);
                    break;

                case LogTargetType.Packet:
                    CreatePacketLog(_packetLoggerConfig, target);
                    break;
                }
            }

            /**
             * Vagabondan 2017-07-16: changed file logger init because of exception*/
            if (config.Targets.Count(x => x.Type == LogTargetType.File) > 0) // if we have added new file loggers.
            {
                Log.Logger = _mainConfig.CreateLogger();                     // recreate the global logger.
            }
            PacketLogger = _packetLoggerConfig.CreateLogger();               // create the packet logger too even if doesn't really contain any outputs.
        }
        /// <summary>
        /// Sets the log level for logger to either the level provided by the config or an public default.
        /// </summary>
        /// <param name="logger">The logger to set the level of.</param>
        /// <param name="config">The LogConfig to look for the level setting in.</param>
        private static void SetupLogLevel(log4netLogger logger, ILogConfig config)
        {
            logger.Level = logger.Hierarchy.LevelMap[config.LogLevel];

            if (logger.Level == null)
            {
                logger.Level = log4net.Core.Level.Info;
            }

            if (logger.Level == GetAuditLevel())
            {
                logger.Level = Level.Info;
                logger.Log(Level.Warn, $"Log level was set to {AuditLogName} which is not a valid log level. To enable audit logging, set the auditLog configuration option to true. Log level will be treated as INFO for this run.", null);
            }

            if (IsLogLevelDeprecated(logger.Level))
            {
                logger.Log(Level.Warn, string.Format(
                               "The log level, {0}, set in your configuration file has been deprecated. The agent will still log correctly, but you should change to a supported logging level as described in newrelic.config or the online documentation.",
                               logger.Level.ToString()), null);
            }
        }
        /// <summary>
        /// Sets up a rolling file appender using defaults shared for all our rolling file appenders.
        /// </summary>
        /// <param name="config">The configuration for the appender.</param>
        /// <param name="fileName">The name of the file this appender will write to.</param>
        /// <param name="appenderName">The name of this appender.</param>
        /// <remarks>This does not call appender.ActivateOptions or add the appender to the logger.</remarks>
        private static RollingFileAppender SetupRollingFileAppender(ILogConfig config, string fileName, string appenderName, ILayout layout)
        {
            var log = log4net.LogManager.GetLogger(typeof(AgentManager));

            // check that the log file is accessible
            try
            {
                using (File.Open(fileName, FileMode.OpenOrCreate, FileAccess.Write, FileShare.Write)) { }
            }
            catch (Exception exception)
            {
                log.ErrorFormat("Unable to write the {0} log to \"{1}\": {2}", appenderName, fileName, exception.Message);
                throw exception;
            }

            try
            {
                var appender = new RollingFileAppender();

                appender.LockingModel       = GetFileLockingModel(config);
                appender.Layout             = layout;
                appender.File               = fileName;
                appender.Encoding           = System.Text.Encoding.UTF8;
                appender.AppendToFile       = true;
                appender.RollingStyle       = RollingFileAppender.RollingMode.Size;
                appender.MaxSizeRollBackups = 4;
                appender.MaxFileSize        = 50 * 1024 * 1024; // 50MB
                appender.StaticLogFileName  = true;
                appender.ImmediateFlush     = true;

                return(appender);
            }
            catch (Exception exception)
            {
                log.ErrorFormat("Unable to configure the {0} log file appender for \"{1}\": {2}", appenderName, fileName, exception.Message);
                throw exception;
            }
        }
Beispiel #30
0
        public void EmitConfiguration(ILogConfig config)
        {
            // read the root folder for logs.
            _rootFolder = string.IsNullOrEmpty(config.Root) ? "logs" : config.Root;
            var rootPath = FileHelpers.GetAbsolutePath(_rootFolder);

            // make sure log root exists.
            if (!Directory.Exists(rootPath))
            {
                Directory.CreateDirectory(rootPath);
            }

            // loop through file log targets from the config
            foreach (var target in config.Targets)
            {
                if (!target.Enabled)
                {
                    continue;
                }

                switch (target.Type)
                {
                case LogTargetType.File:
                    CreateFileLog(_mainConfig, target);
                    break;

                case LogTargetType.Packet:
                    CreatePacketLog(_packetLoggerConfig, target);
                    break;
                }
            }

            Log.Logger = _mainConfig.CreateLogger();           // create the global logger.

            PacketLogger = _packetLoggerConfig.CreateLogger(); // create the packet logger too even if doesn't really contain any outputs.
        }
 public void ApplyConfiguration( ILogConfig c )
 {
     _logConfig = c.Clone();
 }
Beispiel #32
0
 public InferenceClassificationComparisonLogger(ILogConfig config)
 {
     this.dataLogger = new DataLogger(config, InferenceClassificationComparisonLogger.Columns, (from column in InferenceClassificationComparisonLogger.Columns
                                                                                                select typeof(string)).ToList <Type>());
 }
Beispiel #33
0
 public void SetUp()
 {
     _cfg = Reflector.LoadInstance <ILogConfig>("RexToy.Logging.XmlLogConfig, RexToy.Common", args: @"..\..\Logging\log.xml");
 }
Beispiel #34
0
 public void SetUp()
 {
     string type = "RexToy.Logging.XmlLogConfig, RexToy.Common";
     _cfg1 = Reflector.LoadInstance<ILogConfig>(type, args: @"..\..\Logging\log1.xml");
     _cfg2 = Reflector.LoadInstance<ILogConfig>(type, args: @"..\..\Logging\log2.xml");
 }
Beispiel #35
0
 public Logger(string name, ILogConfig cfg)
 {
     this._name = name;
     Config(cfg);
 }
 public ServiceHostConfiguration( ILogConfig c )
 {
     ApplyConfiguration( c );
 }
Beispiel #37
0
 public void SetUp()
 {
     _cfg = Reflector.LoadInstance<ILogConfig>("RexToy.Logging.XmlLogConfig, RexToy.Common", args: @"..\..\Logging\log.xml");
 }
        public LogManager(IConfigManager configManager)
        {
            _config = configManager.LogConfig;

            Initialize();
        }
 public void ApplyConfiguration( ILogServiceConfig s )
 {
     if( _logConfig != null )
         _logConfig = _logConfig.CombineWith( s );
 }
Beispiel #40
0
 public LogManager(IConfigManager configManager)
 {
     _config = configManager.LogConfig;
 }
Beispiel #41
0
        /// <summary>
        /// Updates all VMLogServiceConfig to reflect the Log configuration set as parameter
        /// If this method if called in response to a ConfigCanged from the interceptor, we don't track changes
        /// If this method is called in response to a LoadXMLConfig, we do track changes
        /// </summary>
        /// <param name="l"></param>
        /// <param name="isDirty"></param>
        internal void UpdateFrom( ILogConfig l, bool trackChanges )
        {
            bool hasChanged = false;

            foreach( ILogServiceConfig s in l.Services )
            {
                VMLogServiceConfig vmS;

                vmS = Find( s.Name );
                if( vmS != null ) //The vm already exists
                {
                    vmS.UpdateFrom( s, trackChanges );
                }
                else
                {
                    vmS = VMLogServiceConfig.CreateFrom( this, s );
                    EventRegistration( vmS );
                    vmS.UpdateFrom( s, trackChanges );
                    if( trackChanges ) vmS.IsDirty = true; //If we create a new service from another source than the kernel, it must be set to dirty
                    _services.Add( vmS );
                }
            }
            if( l.DoLog != DoLog )
            {
                DoLog = l.DoLog;
                hasChanged = true;
            }

            if( !trackChanges ) IsDirty = false; // If we update from the kernel, conf is no longer dirty
            else if( hasChanged ) IsDirty = true; // If we update from an other source and changes have been made in the logConfig's cocnf, conf is dirty. But if no changes have been made, conf stays the way it was before updating

            if( !trackChanges )
                Debug.Assert( IsDirty == false );
        }