当前位置: 首页>>代码示例>>C#>>正文


C# ILoggerRepository类代码示例

本文整理汇总了C#中ILoggerRepository的典型用法代码示例。如果您正苦于以下问题:C# ILoggerRepository类的具体用法?C# ILoggerRepository怎么用?C# ILoggerRepository使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ILoggerRepository类属于命名空间,在下文中一共展示了ILoggerRepository类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ConfigureAndWatchHandler

			public ConfigureAndWatchHandler(ILoggerRepository repository, FileInfo configFile)
			{
				m_repository = repository;
				m_configFile = configFile;

				// Create a new FileSystemWatcher and set its properties.
				m_watcher = new FileSystemWatcher();

				m_watcher.Path = m_configFile.DirectoryName;
				m_watcher.Filter = m_configFile.Name;

				// Set the notification filters
				m_watcher.NotifyFilter = NotifyFilters.CreationTime | NotifyFilters.LastWrite | NotifyFilters.FileName;

				// Add event handlers. OnChanged will do for all event handlers that fire a FileSystemEventArgs
				m_watcher.Changed += new FileSystemEventHandler(ConfigureAndWatchHandler_OnChanged);
				m_watcher.Created += new FileSystemEventHandler(ConfigureAndWatchHandler_OnChanged);
				m_watcher.Deleted += new FileSystemEventHandler(ConfigureAndWatchHandler_OnChanged);
				m_watcher.Renamed += new RenamedEventHandler(ConfigureAndWatchHandler_OnRenamed);

				// Begin watching.
				m_watcher.EnableRaisingEvents = true;

				// Create the timer that will be used to deliver events. Set as disabled
				m_timer = new Timer(new TimerCallback(OnWatchedFileChange), null, Timeout.Infinite, Timeout.Infinite);
			}
开发者ID:GregoryMaks,项目名称:log4net-201310,代码行数:26,代码来源:XmlConfigurator.ConfigureAndWatchHandler.ClientProfile.WF.cs

示例2: RegisterLogging

        /// <summary>
        ///		Registers loggers within the <see cref="AppDomain"/>
        /// and creates the <see cref="ILoggerRepository"/> using 
        /// provided <paramref name="loggerConfiguration"/>.
        /// 
        /// Sample logging welcome message is done using <paramref name="type"/>
        /// </summary>
        /// <param name="loggerConfiguration"></param>
        /// <param name="type"></param>
        public void RegisterLogging(string loggerConfiguration, Type type)
        {
            try
            {
                _repository = LogManager.CreateRepository(NomadConstants.NOMAD_LOGGER_REPOSITORY);
            }
            catch (LogException)
            {
                // the repository is already defined
                // this situation should not happen in real life situation
                // but can occur in syntetic testing
                _logger = LogManager.GetLogger(NomadConstants.NOMAD_LOGGER_REPOSITORY, type);
                return;
            }

            try
            {
                var file = new FileInfo(loggerConfiguration);
                XmlConfigurator.Configure(_repository, file);
            }
            catch (Exception)
            {
                // NOTE: eat the exception here - fallback mechanism if user not specified other ways
                BasicConfigurator.Configure(_repository);
            }

            _logger = LogManager.GetLogger(NomadConstants.NOMAD_LOGGER_REPOSITORY, type);
            _logger.Info("The modules logger is enabled at levels:");

            _logger.Info(string.Format("Debug: {0}", _logger.IsDebugEnabled));
            _logger.Info(string.Format("Info: {0}", _logger.IsInfoEnabled));
            _logger.Info(string.Format("Warn: {0}", _logger.IsWarnEnabled));
            _logger.Info(string.Format("Error: {0}", _logger.IsErrorEnabled));
            _logger.Info(string.Format("Fatal: {0}", _logger.IsFatalEnabled));
        }
开发者ID:NomadPL,项目名称:Nomad,代码行数:44,代码来源:LoggingHelper.cs

示例3: CreateLogger

		/// <summary>
		/// Create a new <see cref="Logger" /> instance
		/// </summary>
		/// <param name="repository">The <see cref="ILoggerRepository" /> that will own the <see cref="Logger" />.</param>
		/// <param name="name">The name of the <see cref="Logger" />.</param>
		/// <returns>The <see cref="Logger" /> instance for the specified name.</returns>
		/// <remarks>
		/// <para>
		/// Create a new <see cref="Logger" /> instance with the 
		/// specified name.
		/// </para>
		/// <para>
		/// Called by the <see cref="Hierarchy"/> to create
		/// new named <see cref="Logger"/> instances.
		/// </para>
		/// <para>
		/// If the <paramref name="name"/> is <c>null</c> then the root logger
		/// must be returned.
		/// </para>
		/// </remarks>
		public Logger CreateLogger(ILoggerRepository repository, string name) 
		{
			if (name == null)
			{
				return new RootLogger(repository.LevelMap.LookupWithDefault(Level.Debug));
			}
			return new LoggerImpl(name);
		}
开发者ID:ZhenghaiYe,项目名称:iveely,代码行数:28,代码来源:DefaultLoggerFactory.cs

示例4: ReloadLevels

		private void ReloadLevels(ILoggerRepository repository)
		{
			LevelMap levelMap = repository.LevelMap;

			m_levelDebug = levelMap.LookupWithDefault(Level.Debug);
			m_levelInfo = levelMap.LookupWithDefault(Level.Info);
			m_levelWarn = levelMap.LookupWithDefault(Level.Warn);
			m_levelError = levelMap.LookupWithDefault(Level.Error);
			m_levelFatal = levelMap.LookupWithDefault(Level.Fatal);
		}
开发者ID:Redi0,项目名称:meijing-ui,代码行数:10,代码来源:MarshalByRefLogImpl.cs

示例5: Configure

		/// <summary>
		/// Configures the SecurityContextProvider
		/// </summary>
		/// <param name="sourceAssembly">The assembly that this attribute was defined on.</param>
		/// <param name="targetRepository">The repository to configure.</param>
		/// <remarks>
		/// <para>
		/// Creates a provider instance from the <see cref="ProviderType"/> specified.
		/// Sets this as the default security context provider <see cref="SecurityContextProvider.DefaultProvider"/>.
		/// </para>
		/// </remarks>
		override public void Configure(Assembly sourceAssembly, ILoggerRepository targetRepository) {
			if (m_providerType == null) {
				LogLog.Error(declaringType, "Attribute specified on assembly [" + sourceAssembly.FullName + "] with null ProviderType.");
			} else {
				LogLog.Debug(declaringType, "Creating provider of type [" + m_providerType.FullName + "]");

				SecurityContextProvider provider = Activator.CreateInstance(m_providerType) as SecurityContextProvider;

				if (provider == null) {
					LogLog.Error(declaringType, "Failed to create SecurityContextProvider instance of type [" + m_providerType.Name + "].");
				} else {
					SecurityContextProvider.DefaultProvider = provider;
				}
			}
		}
开发者ID:GodLesZ,项目名称:svn-dump,代码行数:26,代码来源:SecurityContextProviderAttribute.cs

示例6: Attach

		/// <summary>
		/// Attaches this plugin to a <see cref="ILoggerRepository"/>.
		/// </summary>
		/// <param name="repository">The <see cref="ILoggerRepository"/> that this plugin should be attached to.</param>
		/// <remarks>
		/// <para>
		/// A plugin may only be attached to a single repository.
		/// </para>
		/// <para>
		/// This method is called when the plugin is attached to the repository.
		/// </para>
		/// </remarks>
		override public void Attach(ILoggerRepository repository)
		{
			base.Attach(repository);

			// Create the sink and marshal it
			m_sink = new RemoteLoggingSinkImpl(repository); 

			try
			{
				RemotingServices.Marshal(m_sink, m_sinkUri, typeof(log4net.Appender.RemotingAppender.IRemoteLoggingSink));		
			}
			catch(Exception ex)
			{
				LogLog.Error("RemoteLoggingServerPlugin: Failed to Marshal remoting sink", ex);
			}
		}
开发者ID:WolfeReiter,项目名称:clamav-csharp-client,代码行数:28,代码来源:RemoteLoggingServerPlugin.cs

示例7: LogWriter

        public LogWriter(ILoggerRepository loggerRepository, object source)
        {
            if (loggerRepository == null)
            {
                throw new ArgumentNullException("loggerRepository");
            }

            this.loggerRepository = loggerRepository;

            if (source != null)
            {
                sourceType = source.GetType();
            }
            else
            {
                sourceType = MethodBase.GetCurrentMethod().DeclaringType;
            }
        }
开发者ID:affecto,项目名称:dotnet-Logging,代码行数:18,代码来源:LogWriter.cs

示例8: ReloadLevels

            private static void ReloadLevels(ILoggerRepository repository)
            {
                LevelMap levelMap = repository.LevelMap;

                _levelTrace = levelMap.LookupWithDefault(Level.Trace);
                _levelDebug = levelMap.LookupWithDefault(Level.Debug);
                _levelInfo = levelMap.LookupWithDefault(Level.Info);
                _levelWarn = levelMap.LookupWithDefault(Level.Warn);
                _levelError = levelMap.LookupWithDefault(Level.Error);
                _levelFatal = levelMap.LookupWithDefault(Level.Fatal);
//                LevelLogError = levelMap.LookupWithDefault(LevelLogError);
//                LevelLogInfo = levelMap.LookupWithDefault(LevelLogInfo);

                //// Register custom logging levels with the default LoggerRepository
//                LogManager.GetRepository().LevelMap.Add(LevelLogInfo);
//                LogManager.GetRepository().LevelMap.Add(LevelLogError);

            }
开发者ID:VegasoftTI,项目名称:Dnn.Platform,代码行数:18,代码来源:LoggerSourceImpl.cs

示例9: GetReconstructedLoggingEvent

        public LoggingEvent GetReconstructedLoggingEvent(ILoggerRepository renderingRepo)
        {
            LoggingEvent ret = new LoggingEvent(null, renderingRepo, null, _LoggingEvent.Level, _MessageObject, _LoggedException);

            BindingFlags eFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
            FieldInfo pi;

            LoggingEventData data = _LoggingEvent.GetLoggingEventData(FixFlags.None);
            //reset message so it gets rendered again
            data.Message = null;

            pi = ret.GetType().GetField("m_data", eFlags);
            if (pi != null)
            {
                pi.SetValue(ret, data);
            }

            //reflectivly set the rest of the properties.
            ret.Fix = FixFlags.Exception | FixFlags.Message;
            return ret;
        }
开发者ID:edwinf,项目名称:WCFAppender-log4net,代码行数:21,代码来源:LogEventWrapper.cs

示例10: Configure

		/// <summary>
		/// Automatically configures the <see cref="ILoggerRepository"/> using settings
		/// stored in the application's configuration file.
		/// </summary>
		/// <remarks>
		/// Each application has a configuration file. This has the
		/// same name as the application with '.config' appended.
		/// This file is XML and calling this function prompts the
		/// configurator to look in that file for a section called
		/// <c>log4net</c> that contains the configuration data.
		/// </remarks>
		/// <param name="repository">The repository to configure.</param>
		static public void Configure(ILoggerRepository repository) 
		{
			LogLog.Debug("DOMConfigurator: configuring repository [" + repository.Name + "] using .config file section");

			try
			{
				LogLog.Debug("DOMConfigurator: Application config file is [" + SystemInfo.ConfigurationFileLocation + "]");
			}
			catch
			{
				// ignore error
				LogLog.Debug("DOMConfigurator: Application config file location unknown");
			}

#if NETCF
			// No config file reading stuff. Just go straight for the file
			Configure(repository, new FileInfo(SystemInfo.ConfigurationFileLocation));
#else
			try
			{
				ConfigureFromXML(repository, (XmlElement) System.Configuration.ConfigurationSettings.GetConfig("log4net"));
			}
			catch(System.Configuration.ConfigurationException confEx)
			{
				if (confEx.BareMessage.IndexOf("Unrecognized element") >= 0)
				{
					// Looks like the XML file is not valid
					LogLog.Error("DOMConfigurator: Failed to parse config file. Check your .config file is well formed XML.", confEx);
				}
				else
				{
					// This exception is typically due to the assembly name not being correctly specified in the section type.
					string configSectionStr = "<section name=\"log4net\" type=\"log4net.Config.Log4NetConfigurationSectionHandler," + Assembly.GetExecutingAssembly().FullName + "\" />";
					LogLog.Error("DOMConfigurator: Failed to parse config file. Is the <configSections> specified as: " + configSectionStr, confEx);
				}
			}
#endif
		}
开发者ID:WolfeReiter,项目名称:clamav-csharp-client,代码行数:50,代码来源:DOMConfigurator.cs

示例11: OnLoggerRepositoryCreatedEvent

		/// <summary>
		/// Notify the registered listeners that the repository has been created
		/// </summary>
		/// <param name="repository">The repository that has been created</param>
		/// <remarks>
		/// <para>
		/// Raises the <event cref="LoggerRepositoryCreatedEvent">LoggerRepositoryCreatedEvent</event>
		/// event.
		/// </para>
		/// </remarks>
		protected virtual void OnLoggerRepositoryCreatedEvent(ILoggerRepository repository)
		{
			LoggerRepositoryCreationEventHandler handler = m_loggerRepositoryCreatedEvent;
			if (handler != null)
			{
				handler(this, new LoggerRepositoryCreationEventArgs(repository));
			}
		}
开发者ID:Redi0,项目名称:meijing-ui,代码行数:18,代码来源:CompactRepositorySelector.cs

示例12: GetAllRepositories

		/// <summary>
		/// Gets a list of <see cref="ILoggerRepository"/> objects
		/// </summary>
		/// <returns>an array of all known <see cref="ILoggerRepository"/> objects</returns>
		/// <remarks>
		/// <para>
		/// Gets an array of all of the repositories created by this selector.
		/// </para>
		/// </remarks>
		public ILoggerRepository[] GetAllRepositories()
		{
			lock(this)
			{
				ICollection reps = m_name2repositoryMap.Values;
				ILoggerRepository[] all = new ILoggerRepository[reps.Count];
				reps.CopyTo(all, 0);
				return all;
			}
		}
开发者ID:Redi0,项目名称:meijing-ui,代码行数:19,代码来源:CompactRepositorySelector.cs

示例13: LogManager

 public LogManager(ServerCore parent, FileInfo configFile)
 {
     this._logs = new Dictionary<String, Log>();
     this.Parent = parent;
     XmlConfigurator.ConfigureAndWatch(configFile);
     this._repository = log4net.LogManager.GetRepository();
 }
开发者ID:takeshik,项目名称:metatweet-old,代码行数:7,代码来源:LogManager.cs

示例14: TestFixtureSetUp

        public void TestFixtureSetUp()
        {
            appender = new AsyncAdoAppender
            {
                CommandType = CommandType.Text,
                ConnectionString = connectionString,
                CommandText = commandText,
                ConnectionType = connectionType
            };

            appender.AddParameter(new AdoNetAppenderParameter { DbType = DbType.DateTime, ParameterName = "@log_date", Layout = new RawUtcTimeStampLayout() });
            appender.AddParameter(new AdoNetAppenderParameter { DbType = DbType.String, Size = 255, ParameterName = "@thread", Layout = new Layout2RawLayoutAdapter(new PatternLayout("%thread")) });
            appender.AddParameter(new AdoNetAppenderParameter { DbType = DbType.String, Size = 40, ParameterName = "@log_level", Layout = new Layout2RawLayoutAdapter(new PatternLayout("%level")) });
            appender.AddParameter(new AdoNetAppenderParameter { DbType = DbType.String, Size = 255, ParameterName = "@logger", Layout = new Layout2RawLayoutAdapter(new PatternLayout("%logger")) });
            appender.AddParameter(new AdoNetAppenderParameter { DbType = DbType.String, Size = 4000, ParameterName = "@message", Layout = new Layout2RawLayoutAdapter(new PatternLayout("%message")) });
            appender.AddParameter(new AdoNetAppenderParameter { DbType = DbType.String, Size = 4000, ParameterName = "@exception", Layout = new Layout2RawLayoutAdapter(new PatternLayout("%exception")) });
            appender.AddParameter(new AdoNetAppenderParameter { DbType = DbType.String, Size = 200, ParameterName = "@application", Layout = new Layout2RawLayoutAdapter(new PatternLayout(ApplicationName)) });

            appender.Threshold = ErrorLevel;
            appender.BufferSize = -1;
            appender.ActivateOptions();

            rep = LogManager.CreateRepository(Guid.NewGuid().ToString());
            BasicConfigurator.Configure(rep, appender);
            LogsDBAccess.RemoveMatchingLogEntries(ErrorLevel, ErrorMessage, ApplicationName);
        }
开发者ID:JohnDRoach,项目名称:Log4Net.Async,代码行数:26,代码来源:AsyncAdoAppenderTest.cs

示例15: ConfigureRepositoryWithLayoutWithMessageProperties

        private void ConfigureRepositoryWithLayoutWithMessageProperties(PatternLayout layout)
        {
            LogManager.Shutdown();

            _Rep = LogManager.CreateRepository(Guid.NewGuid().ToString());
            _Appender = new RabbitMQAppender { Layout = layout };
            _Appender.ExchangeProperties.Name = "log4Net.RabbitMQ.Tests";
            _Appender.ExchangeProperties.ExchangeType = "fanout";
            _Appender.ExchangeProperties.Durable = true;

            _Appender.MessageProperties.AppId = Guid.NewGuid().ToString();
            _Appender.MessageProperties.ContentType = new PatternLayout("text/plain");
            _Appender.MessageProperties.Persistent = true;
            _Appender.MessageProperties.Priority = new PatternLayout("%property{priority}");
            _Appender.MessageProperties.Topic = new PatternLayout("%property{topic}");

            // An app could do something like this to customize the message priority and routing key on a message by message 
            // basis.

            ThreadContext.Properties["priority"] = "0";
            ThreadContext.Properties["topic"] = "log4net.RabbitMQ.Tests";

            _Appender.HostName = this.hostName;

            _Appender.ActivateOptions();

            BasicConfigurator.Configure(_Rep, _Appender);
            _Log = LogManager.GetLogger(_Rep.Name, GetType());

            BasicConfigurator.Configure(new ConsoleAppender { Layout = new SimpleLayout() });
        }
开发者ID:vebin,项目名称:log4net.RabbitMQ,代码行数:31,代码来源:rabbitmq_appender_spec.cs


注:本文中的ILoggerRepository类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。