internal void ApplyTo(AppenderSkeleton appender) { if (_filter != null) { appender.AddFilter(_filter.CreateFilter()); } }
public ActiveLoggerFilterScope(string activeLogger) { ILoggerRepository repository = LogManager.GetRepository(); repository.Threshold = Level.All; repository.Properties[scopeKey] = activeLogger; foreach (IAppender appender in LogManager.GetRepository().GetAppenders()) { AppenderSkeleton appenderSkeleton = appender as AppenderSkeleton; if (appenderSkeleton != null) { // only inject ActiveLoggerFilter once if (appenderSkeleton.FilterHead == null || appenderSkeleton.FilterHead.GetType() != typeof(ActiveLoggerFilter)) { // inject ActiveLoggerFilter into the head of the filter list IFilter filter = new ActiveLoggerFilter(scopeKey); filter.ActivateOptions(); filter.Next = appenderSkeleton.FilterHead; // ??? appenderSkeleton.ClearFilters(); // ??? appenderSkeleton.AddFilter(filter); // ??? } } } }
/// <summary> /// Appends inclusive filter to the log /// </summary> /// <param name="minRange">The min range.</param> /// <param name="maxRange">The max range.</param> /// <returns>same syntax</returns> public LogSyntax Filter(LogLevel minRange, LogLevel maxRange) { var filter = new LevelRangeFilter { LevelMin = minRange.ToLog4Net(), LevelMax = maxRange.ToLog4Net(), AcceptOnMatch = true }; filter.ActivateOptions(); _skeleton.AddFilter(filter); //_skeleton.ActivateOptions(); return(this); }