You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4net-dev@logging.apache.org by ni...@apache.org on 2004/12/06 03:22:05 UTC
cvs commit: logging-log4net/src/Filter DenyAllFilter.cs FilterDecision.cs FilterSkeleton.cs IFilter.cs LevelMatchFilter.cs LevelRangeFilter.cs LoggerMatchFilter.cs MdcFilter.cs NdcFilter.cs PropertyFilter.cs StringMatchFilter.cs
nicko 2004/12/05 18:22:05
Modified: src/Filter DenyAllFilter.cs FilterDecision.cs
FilterSkeleton.cs IFilter.cs LevelMatchFilter.cs
LevelRangeFilter.cs LoggerMatchFilter.cs
MdcFilter.cs NdcFilter.cs PropertyFilter.cs
StringMatchFilter.cs
Log:
Updated doc comments
Revision Changes Path
1.4 +8 -4 logging-log4net/src/Filter/DenyAllFilter.cs
Index: DenyAllFilter.cs
===================================================================
RCS file: /home/cvs/logging-log4net/src/Filter/DenyAllFilter.cs,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- DenyAllFilter.cs 23 Feb 2004 03:18:03 -0000 1.3
+++ DenyAllFilter.cs 6 Dec 2004 02:22:05 -0000 1.4
@@ -26,14 +26,16 @@
/// This filter drops all <see cref="LoggingEvent"/>.
/// </summary>
/// <remarks>
+ /// <para>
/// You can add this filter to the end of a filter chain to
/// switch from the default "accept all unless instructed otherwise"
/// filtering behavior to a "deny all unless instructed otherwise"
- /// behavior.
+ /// behavior.
+ /// </para>
/// </remarks>
/// <author>Nicko Cadell</author>
/// <author>Gert Driesen</author>
- public class DenyAllFilter : FilterSkeleton
+ public sealed class DenyAllFilter : FilterSkeleton
{
#region Constructors
@@ -51,15 +53,17 @@
/// <summary>
/// Always returns the integer constant <see cref="FilterDecision.Deny"/>
/// </summary>
+ /// <param name="loggingEvent">the LoggingEvent to filter</param>
+ /// <returns>Always returns <see cref="FilterDecision.Deny"/></returns>
/// <remarks>
+ /// <para>
/// Ignores the event being logged and just returns
/// <see cref="FilterDecision.Deny"/>. This can be used to change the default filter
/// chain behavior from <see cref="FilterDecision.Accept"/> to <see cref="FilterDecision.Deny"/>. This filter
/// should only be used as the last filter in the chain
/// as any further filters will be ignored!
+ /// </para>
/// </remarks>
- /// <param name="loggingEvent">the LoggingEvent to filter</param>
- /// <returns>Always returns <see cref="FilterDecision.Deny"/></returns>
override public FilterDecision Decide(LoggingEvent loggingEvent)
{
return FilterDecision.Deny;
1.3 +2 -1 logging-log4net/src/Filter/FilterDecision.cs
Index: FilterDecision.cs
===================================================================
RCS file: /home/cvs/logging-log4net/src/Filter/FilterDecision.cs,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- FilterDecision.cs 16 Feb 2004 02:10:53 -0000 1.2
+++ FilterDecision.cs 6 Dec 2004 02:22:05 -0000 1.3
@@ -26,7 +26,9 @@
/// The return result from <see cref="IFilter.Decide"/>
/// </summary>
/// <remarks>
+ /// <para>
/// The return result from <see cref="IFilter.Decide"/>
+ /// </para>
/// </remarks>
public enum FilterDecision : int
{
@@ -48,5 +50,4 @@
/// </summary>
Accept = 1,
}
-
}
1.5 +44 -30 logging-log4net/src/Filter/FilterSkeleton.cs
Index: FilterSkeleton.cs
===================================================================
RCS file: /home/cvs/logging-log4net/src/Filter/FilterSkeleton.cs,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- FilterSkeleton.cs 30 May 2004 11:04:08 -0000 1.4
+++ FilterSkeleton.cs 6 Dec 2004 02:22:05 -0000 1.5
@@ -22,38 +22,46 @@
namespace log4net.Filter
{
/// <summary>
- /// Users should extend this class to implement customized logging
- /// event filtering.
+ /// Subclass this type to implement customized logging event filtering
/// </summary>
/// <remarks>
- /// <para>Users should extend this class to implement customized logging
+ /// <para>
+ /// Users should extend this class to implement customized logging
/// event filtering. Note that <see cref="log4net.Repository.Hierarchy.Logger"/> and
/// <see cref="log4net.Appender.AppenderSkeleton"/>, the parent class of all standard
/// appenders, have built-in filtering rules. It is suggested that you
/// first use and understand the built-in rules before rushing to write
- /// your own custom filters.</para>
- ///
- /// <para>This abstract class assumes and also imposes that filters be
+ /// your own custom filters.
+ /// </para>
+ /// <para>
+ /// This abstract class assumes and also imposes that filters be
/// organized in a linear chain. The <see cref="Decide"/>
/// method of each filter is called sequentially, in the order of their
- /// addition to the chain.</para>
- ///
- /// <para>The <see cref="Decide"/> method must return one
- /// of the integer constants <see cref="FilterDecision.Deny"/>, <see cref="FilterDecision.Neutral"/> or <see cref="FilterDecision.Accept"/>.</para>
- ///
- /// <para>If the value <see cref="FilterDecision.Deny"/> is returned, then the log event is dropped
- /// immediately without consulting with the remaining filters. </para>
- ///
- /// <para>If the value <see cref="FilterDecision.Neutral"/> is returned, then the next filter
+ /// addition to the chain.
+ /// </para>
+ /// <para>
+ /// The <see cref="Decide"/> method must return one
+ /// of the integer constants <see cref="FilterDecision.Deny"/>,
+ /// <see cref="FilterDecision.Neutral"/> or <see cref="FilterDecision.Accept"/>.
+ /// </para>
+ /// <para>
+ /// If the value <see cref="FilterDecision.Deny"/> is returned, then the log event is dropped
+ /// immediately without consulting with the remaining filters.
+ /// </para>
+ /// <para>
+ /// If the value <see cref="FilterDecision.Neutral"/> is returned, then the next filter
/// in the chain is consulted. If there are no more filters in the
/// chain, then the log event is logged. Thus, in the presence of no
- /// filters, the default behavior is to log all logging events.</para>
- ///
- /// <para>If the value <see cref="FilterDecision.Accept"/> is returned, then the log
- /// event is logged without consulting the remaining filters. </para>
- ///
- /// <para>The philosophy of log4net filters is largely inspired from the
- /// Linux ipchains. </para>
+ /// filters, the default behavior is to log all logging events.
+ /// </para>
+ /// <para>
+ /// If the value <see cref="FilterDecision.Accept"/> is returned, then the log
+ /// event is logged without consulting the remaining filters.
+ /// </para>
+ /// <para>
+ /// The philosophy of log4net filters is largely inspired from the
+ /// Linux ipchains.
+ /// </para>
/// </remarks>
/// <author>Nicko Cadell</author>
/// <author>Gert Driesen</author>
@@ -65,7 +73,9 @@
/// Points to the next filter in the filter chain.
/// </summary>
/// <remarks>
+ /// <para>
/// See <see cref="Next"/> for more information.
+ /// </para>
/// </remarks>
private IFilter m_next;
@@ -89,7 +99,7 @@
/// <see cref="ActivateOptions"/> must be called again.
/// </para>
/// <para>
- /// Typically filter's options become active immediatly on set,
+ /// Typically filter's options become active immediately on set,
/// however this method must still be called.
/// </para>
/// </remarks>
@@ -107,27 +117,31 @@
/// <param name="loggingEvent">The <see cref="LoggingEvent"/> to decide upon</param>
/// <returns>The decision of the filter</returns>
/// <remarks>
- /// <para>If the decision is <see cref="FilterDecision.Deny"/>, then the event will be
+ /// <para>
+ /// If the decision is <see cref="FilterDecision.Deny"/>, then the event will be
/// dropped. If the decision is <see cref="FilterDecision.Neutral"/>, then the next
/// filter, if any, will be invoked. If the decision is <see cref="FilterDecision.Accept"/> then
/// the event will be logged without consulting with other filters in
- /// the chain.</para>
- ///
- /// <para>This method is marked <c>abstract</c> and must be implemented
- /// in a subclass.</para>
+ /// the chain.
+ /// </para>
+ /// <para>
+ /// This method is marked <c>abstract</c> and must be implemented
+ /// in a subclass.
+ /// </para>
/// </remarks>
abstract public FilterDecision Decide(LoggingEvent loggingEvent);
/// <summary>
- /// Property to get and set the next filter in the filter
- /// chain of responsibility.
+ /// Property to get and set the next filter
/// </summary>
/// <value>
/// The next filter in the chain
/// </value>
/// <remarks>
+ /// <para>
/// Filters are typically composed into chains. This property allows the next filter in
/// the chain to be accessed.
+ /// </para>
/// </remarks>
public IFilter Next
{
1.4 +36 -26 logging-log4net/src/Filter/IFilter.cs
Index: IFilter.cs
===================================================================
RCS file: /home/cvs/logging-log4net/src/Filter/IFilter.cs,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- IFilter.cs 23 Feb 2004 03:18:03 -0000 1.3
+++ IFilter.cs 6 Dec 2004 02:22:05 -0000 1.4
@@ -23,39 +23,46 @@
namespace log4net.Filter
{
/// <summary>
- /// Users should implement this interface to implement customized logging
- /// event filtering.
+ /// Implement this interface to provide customized logging event filtering
/// </summary>
/// <remarks>
- /// <para>Users should implement this interface to implement customized logging
+ /// <para>
+ /// Users should implement this interface to implement customized logging
/// event filtering. Note that <see cref="log4net.Repository.Hierarchy.Logger"/> and
/// <see cref="log4net.Appender.AppenderSkeleton"/>, the parent class of all standard
/// appenders, have built-in filtering rules. It is suggested that you
/// first use and understand the built-in rules before rushing to write
- /// your own custom filters.</para>
- ///
- /// <para>This abstract class assumes and also imposes that filters be
+ /// your own custom filters.
+ /// </para>
+ /// <para>
+ /// This abstract class assumes and also imposes that filters be
/// organized in a linear chain. The <see cref="Decide"/>
/// method of each filter is called sequentially, in the order of their
- /// addition to the chain.</para>
- ///
- /// <para>The <see cref="Decide"/> method must return one
+ /// addition to the chain.
+ /// </para>
+ /// <para>
+ /// The <see cref="Decide"/> method must return one
/// of the integer constants <see cref="FilterDecision.Deny"/>,
- /// <see cref="FilterDecision.Neutral"/> or <see cref="FilterDecision.Accept"/>.</para>
- ///
- /// <para>If the value <see cref="FilterDecision.Deny"/> is returned, then the log event is dropped
- /// immediately without consulting with the remaining filters. </para>
- ///
- /// <para>If the value <see cref="FilterDecision.Neutral"/> is returned, then the next filter
+ /// <see cref="FilterDecision.Neutral"/> or <see cref="FilterDecision.Accept"/>.
+ /// </para>
+ /// <para>
+ /// If the value <see cref="FilterDecision.Deny"/> is returned, then the log event is dropped
+ /// immediately without consulting with the remaining filters.
+ /// </para>
+ /// <para>
+ /// If the value <see cref="FilterDecision.Neutral"/> is returned, then the next filter
/// in the chain is consulted. If there are no more filters in the
/// chain, then the log event is logged. Thus, in the presence of no
- /// filters, the default behavior is to log all logging events.</para>
- ///
- /// <para>If the value <see cref="FilterDecision.Accept"/> is returned, then the log
- /// event is logged without consulting the remaining filters. </para>
- ///
- /// <para>The philosophy of log4net filters is largely inspired from the
- /// Linux ipchains.</para>
+ /// filters, the default behavior is to log all logging events.
+ /// </para>
+ /// <para>
+ /// If the value <see cref="FilterDecision.Accept"/> is returned, then the log
+ /// event is logged without consulting the remaining filters.
+ /// </para>
+ /// <para>
+ /// The philosophy of log4net filters is largely inspired from the
+ /// Linux ipchains.
+ /// </para>
/// </remarks>
/// <author>Nicko Cadell</author>
/// <author>Gert Driesen</author>
@@ -67,24 +74,27 @@
/// <param name="loggingEvent">The LoggingEvent to decide upon</param>
/// <returns>The decision of the filter</returns>
/// <remarks>
- /// <para>If the decision is <see cref="FilterDecision.Deny"/>, then the event will be
+ /// <para>
+ /// If the decision is <see cref="FilterDecision.Deny"/>, then the event will be
/// dropped. If the decision is <see cref="FilterDecision.Neutral"/>, then the next
/// filter, if any, will be invoked. If the decision is <see cref="FilterDecision.Accept"/> then
/// the event will be logged without consulting with other filters in
- /// the chain.</para>
+ /// the chain.
+ /// </para>
/// </remarks>
FilterDecision Decide(LoggingEvent loggingEvent);
/// <summary>
- /// Property to get and set the next filter in the filter
- /// chain of responsibility.
+ /// Property to get and set the next filter
/// </summary>
/// <value>
/// The next filter in the chain
/// </value>
/// <remarks>
+ /// <para>
/// Filters are typically composed into chains. This property allows the next filter in
/// the chain to be accessed.
+ /// </para>
/// </remarks>
IFilter Next { get; set; }
}
1.4 +24 -5 logging-log4net/src/Filter/LevelMatchFilter.cs
Index: LevelMatchFilter.cs
===================================================================
RCS file: /home/cvs/logging-log4net/src/Filter/LevelMatchFilter.cs,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- LevelMatchFilter.cs 23 Feb 2004 03:18:03 -0000 1.3
+++ LevelMatchFilter.cs 6 Dec 2004 02:22:05 -0000 1.4
@@ -28,13 +28,15 @@
/// This is a very simple filter based on <see cref="Level"/> matching.
/// </summary>
/// <remarks>
- /// <para>The filter admits two options <see cref="LevelToMatch"/> and
+ /// <para>
+ /// The filter admits two options <see cref="LevelToMatch"/> and
/// <see cref="AcceptOnMatch"/>. If there is an exact match between the value
/// of the <see cref="LevelToMatch"/> option and the <see cref="Level"/> of the
/// <see cref="LoggingEvent"/>, then the <see cref="Decide"/> method returns <see cref="FilterDecision.Accept"/> in
/// case the <see cref="AcceptOnMatch"/> option value is set
/// to <c>true</c>, if it is <c>false</c> then
- /// <see cref="FilterDecision.Deny"/> is returned.</para>
+ /// <see cref="FilterDecision.Deny"/> is returned.
+ /// </para>
/// </remarks>
/// <author>Nicko Cadell</author>
/// <author>Gert Driesen</author>
@@ -66,11 +68,19 @@
#endregion
/// <summary>
+ /// <see cref="FilterDecision.Accept"/> when matching <see cref="LevelToMatch"/>
+ /// </summary>
+ /// <remarks>
+ /// <para>
/// The <see cref="AcceptOnMatch"/> property is a flag that determines
/// the behavior when a matching <see cref="Level"/> is found. If the
/// flag is set to true then the filter will <see cref="FilterDecision.Accept"/> the
/// logging event, otherwise it will <see cref="FilterDecision.Deny"/> the event.
- /// </summary>
+ /// </para>
+ /// <para>
+ /// The default is <c>true</c> i.e. to <see cref="FilterDecision.Accept"/> the event.
+ /// </para>
+ /// </remarks>
public bool AcceptOnMatch
{
get { return m_acceptOnMatch; }
@@ -80,6 +90,13 @@
/// <summary>
/// The <see cref="Level"/> that the filter will match
/// </summary>
+ /// <remarks>
+ /// <para>
+ /// The level that this filter will attempt to match against the
+ /// <see cref="LoggingEvent"/> level. If a match is found then
+ /// the result depends on the value of <see cref="AcceptOnMatch"/>.
+ /// </para>
+ /// </remarks>
public Level LevelToMatch
{
get { return m_levelToMatch; }
@@ -91,16 +108,18 @@
/// <summary>
/// Tests if the <see cref="Level"/> of the logging event matches that of the filter
/// </summary>
+ /// <param name="loggingEvent">the event to filter</param>
+ /// <returns>see remarks</returns>
/// <remarks>
+ /// <para>
/// If the <see cref="Level"/> of the event matches the level of the
/// filter then the result of the function depends on the
/// value of <see cref="AcceptOnMatch"/>. If it is true then
/// the function will return <see cref="FilterDecision.Accept"/>, it it is false then it
/// will return <see cref="FilterDecision.Deny"/>. If the <see cref="Level"/> does not match then
/// the result will be the opposite of when it does match.
+ /// </para>
/// </remarks>
- /// <param name="loggingEvent">the event to filter</param>
- /// <returns>see remarks</returns>
override public FilterDecision Decide(LoggingEvent loggingEvent)
{
if (loggingEvent == null)
1.4 +31 -5 logging-log4net/src/Filter/LevelRangeFilter.cs
Index: LevelRangeFilter.cs
===================================================================
RCS file: /home/cvs/logging-log4net/src/Filter/LevelRangeFilter.cs,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- LevelRangeFilter.cs 23 Feb 2004 03:18:03 -0000 1.3
+++ LevelRangeFilter.cs 6 Dec 2004 02:22:05 -0000 1.4
@@ -28,13 +28,15 @@
/// This is a simple filter based on <see cref="Level"/> matching.
/// </summary>
/// <remarks>
- /// <para>The filter admits three options <see cref="LevelMin"/> and <see cref="LevelMax"/>
+ /// <para>
+ /// The filter admits three options <see cref="LevelMin"/> and <see cref="LevelMax"/>
/// that determine the range of priorities that are matched, and
/// <see cref="AcceptOnMatch"/>. If there is a match between the range
/// of priorities and the <see cref="Level"/> of the <see cref="LoggingEvent"/>, then the
/// <see cref="Decide"/> method returns <see cref="FilterDecision.Accept"/> in case the <see cref="AcceptOnMatch"/>
/// option value is set to <c>true</c>, if it is <c>false</c>
- /// then <see cref="FilterDecision.Deny"/> is returned. If there is no match, <see cref="FilterDecision.Deny"/> is returned.</para>
+ /// then <see cref="FilterDecision.Deny"/> is returned. If there is no match, <see cref="FilterDecision.Deny"/> is returned.
+ /// </para>
/// </remarks>
/// <author>Nicko Cadell</author>
/// <author>Gert Driesen</author>
@@ -71,11 +73,19 @@
#endregion
/// <summary>
+ /// <see cref="FilterDecision.Accept"/> when matching <see cref="LevelMin"/> and <see cref="LevelMax"/>
+ /// </summary>
+ /// <remarks>
+ /// <para>
/// The <see cref="AcceptOnMatch"/> property is a flag that determines
/// the behavior when a matching <see cref="Level"/> is found. If the
/// flag is set to true then the filter will <see cref="FilterDecision.Accept"/> the
/// logging event, otherwise it will <see cref="FilterDecision.Neutral"/> the event.
- /// </summary>
+ /// </para>
+ /// <para>
+ /// The default is <c>true</c> i.e. to <see cref="FilterDecision.Accept"/> the event.
+ /// </para>
+ /// </remarks>
public bool AcceptOnMatch
{
get { return m_acceptOnMatch; }
@@ -85,6 +95,13 @@
/// <summary>
/// Set the minimum matched <see cref="Level"/>
/// </summary>
+ /// <remarks>
+ /// <para>
+ /// The minimum level that this filter will attempt to match against the
+ /// <see cref="LoggingEvent"/> level. If a match is found then
+ /// the result depends on the value of <see cref="AcceptOnMatch"/>.
+ /// </para>
+ /// </remarks>
public Level LevelMin
{
get { return m_levelMin; }
@@ -94,6 +111,13 @@
/// <summary>
/// Sets the maximum matched <see cref="Level"/>
/// </summary>
+ /// <remarks>
+ /// <para>
+ /// The maximum level that this filter will attempt to match against the
+ /// <see cref="LoggingEvent"/> level. If a match is found then
+ /// the result depends on the value of <see cref="AcceptOnMatch"/>.
+ /// </para>
+ /// </remarks>
public Level LevelMax
{
get { return m_levelMax; }
@@ -105,16 +129,18 @@
/// <summary>
/// Check if the event should be logged.
/// </summary>
+ /// <param name="loggingEvent">the logging event to check</param>
+ /// <returns>see remarks</returns>
/// <remarks>
+ /// <para>
/// If the <see cref="Level"/> of the logging event is outside the range
/// matched by this filter then <see cref="FilterDecision.Deny"/>
/// is returned. If the <see cref="Level"/> is matched then the value of
/// <see cref="AcceptOnMatch"/> is checked. If it is true then
/// <see cref="FilterDecision.Accept"/> is returned, otherwise
/// <see cref="FilterDecision.Neutral"/> is returned.
+ /// </para>
/// </remarks>
- /// <param name="loggingEvent">the logging event to check</param>
- /// <returns>see remarks</returns>
override public FilterDecision Decide(LoggingEvent loggingEvent)
{
if (loggingEvent == null)
1.4 +21 -6 logging-log4net/src/Filter/LoggerMatchFilter.cs
Index: LoggerMatchFilter.cs
===================================================================
RCS file: /home/cvs/logging-log4net/src/Filter/LoggerMatchFilter.cs,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- LoggerMatchFilter.cs 23 Feb 2004 03:18:03 -0000 1.3
+++ LoggerMatchFilter.cs 6 Dec 2004 02:22:05 -0000 1.4
@@ -28,13 +28,15 @@
/// Simple filter to match a string in the event's logger name.
/// </summary>
/// <remarks>
- /// <para>The works very similar to the <see cref="LevelMatchFilter"/>. It admits two
+ /// <para>
+ /// The works very similar to the <see cref="LevelMatchFilter"/>. It admits two
/// options <see cref="LoggerToMatch"/> and <see cref="AcceptOnMatch"/>. If the
/// <see cref="LoggingEvent.LoggerName"/> of the <see cref="LoggingEvent"/> starts
/// with the value of the <see cref="LoggerToMatch"/> option, then the
/// <see cref="Decide"/> method returns <see cref="FilterDecision.Accept"/> in
/// case the <see cref="AcceptOnMatch"/> option value is set to <c>true</c>,
- /// if it is <c>false</c> then <see cref="FilterDecision.Deny"/> is returned.</para>
+ /// if it is <c>false</c> then <see cref="FilterDecision.Deny"/> is returned.
+ /// </para>
/// </remarks>
/// <author>Daniel Cazzulino</author>
public class LoggerMatchFilter : FilterSkeleton
@@ -67,11 +69,19 @@
#region Properties
/// <summary>
+ /// <see cref="FilterDecision.Accept"/> when matching <see cref="LoggerToMatch"/>
+ /// </summary>
+ /// <remarks>
+ /// <para>
/// The <see cref="AcceptOnMatch"/> property is a flag that determines
/// the behavior when a matching <see cref="Level"/> is found. If the
/// flag is set to true then the filter will <see cref="FilterDecision.Accept"/> the
/// logging event, otherwise it will <see cref="FilterDecision.Deny"/> the event.
- /// </summary>
+ /// </para>
+ /// <para>
+ /// The default is <c>true</c> i.e. to <see cref="FilterDecision.Accept"/> the event.
+ /// </para>
+ /// </remarks>
public bool AcceptOnMatch
{
get { return m_acceptOnMatch; }
@@ -82,10 +92,13 @@
/// The <see cref="LoggingEvent.LoggerName"/> that the filter will match
/// </summary>
/// <remarks>
+ /// <para>
/// This filter will attempt to match this value against logger name in
/// the following way. The match will be done against the beginning of the
/// logger name (using <see cref="String.StartsWith"/>). The match is
- /// case sensitive.
+ /// case sensitive. If a match is found then
+ /// the result depends on the value of <see cref="AcceptOnMatch"/>.
+ /// </para>
/// </remarks>
public string LoggerToMatch
{
@@ -100,7 +113,10 @@
/// <summary>
/// Check if this filter should allow the event to be logged
/// </summary>
+ /// <param name="loggingEvent">the event being logged</param>
+ /// <returns>see remarks</returns>
/// <remarks>
+ /// <para>
/// The rendered message is matched against the <see cref="LoggerToMatch"/>.
/// If the <see cref="LoggerToMatch"/> equals the beginning of
/// the incoming <see cref="LoggingEvent.LoggerName"/> (<see cref="String.StartsWith"/>)
@@ -110,9 +126,8 @@
/// the value of <see cref="AcceptOnMatch"/> is checked. If it is
/// true then <see cref="FilterDecision.Accept"/> is returned otherwise
/// <see cref="FilterDecision.Deny"/> is returned.
+ /// </para>
/// </remarks>
- /// <param name="loggingEvent">the event being logged</param>
- /// <returns>see remarks</returns>
override public FilterDecision Decide(LoggingEvent loggingEvent)
{
if (loggingEvent == null)
1.6 +10 -200 logging-log4net/src/Filter/MdcFilter.cs
Index: MdcFilter.cs
===================================================================
RCS file: /home/cvs/logging-log4net/src/Filter/MdcFilter.cs,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- MdcFilter.cs 9 Sep 2004 21:53:13 -0000 1.5
+++ MdcFilter.cs 6 Dec 2004 02:22:05 -0000 1.6
@@ -26,211 +26,21 @@
namespace log4net.Filter
{
/// <summary>
- /// Simple filter to match a string in the <see cref="MDC"/>
+ /// Simple filter to match a keyed string in the <see cref="MDC"/>
/// </summary>
/// <remarks>
- /// Simple filter to match a string in the <see cref="MDC"/>
+ /// <para>
+ /// Simple filter to match a keyed string in the <see cref="MDC"/>
+ /// </para>
+ /// <para>
+ /// As the MDC has been replaced with layered properties the
+ /// <see cref="PropertyFilter"/> should be used instead.
+ /// </para>
/// </remarks>
/// <author>Nicko Cadell</author>
/// <author>Gert Driesen</author>
- public class MdcFilter : FilterSkeleton
+ /*[Obsolete("MdcFilter has been replaced by PropertyFilter")]*/
+ public class MdcFilter : PropertyFilter
{
- #region Member Variables
-
- /// <summary>
- /// Flag to indicate the behavior when we have a match
- /// </summary>
- private bool m_acceptOnMatch = true;
-
- /// <summary>
- /// The string to substring match against the message
- /// </summary>
- private string m_stringToMatch;
-
- /// <summary>
- /// A string regex to match
- /// </summary>
- private string m_stringRegexToMatch;
-
- /// <summary>
- /// A regex object to match (generated from m_stringRegexToMatch)
- /// </summary>
- private Regex m_regexToMatch;
-
- /// <summary>
- /// The key to use to lookup the string
- /// from the MDC
- /// </summary>
- private string m_key;
-
- #endregion
-
- #region Constructors
-
- /// <summary>
- /// Default constructor
- /// </summary>
- public MdcFilter()
- {
- }
-
- #endregion
-
- #region Implementation of IOptionHandler
-
- /// <summary>
- /// Initialize and precompile the Regex if required
- /// </summary>
- /// <remarks>
- /// <para>
- /// This is part of the <see cref="IOptionHandler"/> delayed object
- /// activation scheme. The <see cref="ActivateOptions"/> method must
- /// be called on this object after the configuration properties have
- /// been set. Until <see cref="ActivateOptions"/> is called this
- /// object is in an undefined state and must not be used.
- /// </para>
- /// <para>
- /// If any of the configuration properties are modified then
- /// <see cref="ActivateOptions"/> must be called again.
- /// </para>
- /// </remarks>
- override public void ActivateOptions()
- {
- if (m_stringRegexToMatch != null)
- {
- m_regexToMatch = new Regex(m_stringRegexToMatch, RegexOptions.Compiled);
- }
- }
-
- #endregion
-
- /// <summary>
- /// The <see cref="AcceptOnMatch"/> property is a flag that determines
- /// the behavior when a matching <see cref="Level"/> is found. If the
- /// flag is set to true then the filter will <see cref="FilterDecision.Accept"/> the
- /// logging event, otherwise it will <see cref="FilterDecision.Deny"/> the event.
- /// </summary>
- public bool AcceptOnMatch
- {
- get { return m_acceptOnMatch; }
- set { m_acceptOnMatch = value; }
- }
-
- /// <summary>
- /// The string that will be substring matched against
- /// the rendered message. If the message contains this
- /// string then the filter will match.
- /// </summary>
- public string StringToMatch
- {
- get { return m_stringToMatch; }
- set { m_stringToMatch = value; }
- }
-
- /// <summary>
- /// The regular expression pattern that will be matched against
- /// the rendered message. If the message matches this
- /// pattern then the filter will match.
- /// </summary>
- public string RegexToMatch
- {
- get { return m_stringRegexToMatch; }
- set { m_stringRegexToMatch = value; }
- }
-
- /// <summary>
- /// The key to lookup in the <see cref="MDC"/> and then
- /// match against.
- /// </summary>
- public string Key
- {
- get { return m_key; }
- set { m_key = value; }
- }
-
- #region Override implementation of FilterSkeleton
-
- /// <summary>
- /// Check if this filter should allow the event to be logged
- /// </summary>
- /// <remarks>
- /// The <see cref="MDC"/> is matched against the <see cref="StringToMatch"/>.
- /// If the <see cref="StringToMatch"/> occurs as a substring within
- /// the message then a match will have occurred. If no match occurs
- /// this function will return <see cref="FilterDecision.Neutral"/>
- /// allowing other filters to check the event. If a match occurs then
- /// the value of <see cref="AcceptOnMatch"/> is checked. If it is
- /// true then <see cref="FilterDecision.Accept"/> is returned otherwise
- /// <see cref="FilterDecision.Deny"/> is returned.
- /// </remarks>
- /// <param name="loggingEvent">the event being logged</param>
- /// <returns>see remarks</returns>
- override public FilterDecision Decide(LoggingEvent loggingEvent)
- {
- if (loggingEvent == null)
- {
- throw new ArgumentNullException("loggingEvent");
- }
-
- // Check if we have a key to lookup the MDC value with
- if (m_key == null)
- {
- // We cannot filter so allow the filter chain
- // to continue processing
- return FilterDecision.Neutral;
- }
-
- // Lookup the string to match in from the properties using
- // the key specified.
- object msgObj = loggingEvent.LookupProperty(m_key);
-
- // Use an ObjectRenderer to convert the property value to a string
- string msg = loggingEvent.Repository.RendererMap.FindAndRender(msgObj);
-
- // Check if we have been setup to filter
- if (msg == null || (m_stringToMatch == null && m_regexToMatch == null))
- {
- // We cannot filter so allow the filter chain
- // to continue processing
- return FilterDecision.Neutral;
- }
-
- // Firstly check if we are matching using a regex
- if (m_regexToMatch != null)
- {
- // Check the regex
- if (m_regexToMatch.Match(msg).Success == false)
- {
- // No match, continue processing
- return FilterDecision.Neutral;
- }
-
- // we've got a match
- if (m_acceptOnMatch)
- {
- return FilterDecision.Accept;
- }
- return FilterDecision.Deny;
- }
- else if (m_stringToMatch != null)
- {
- // Check substring match
- if (msg.IndexOf(m_stringToMatch) == -1)
- {
- // No match, continue processing
- return FilterDecision.Neutral;
- }
-
- // we've got a match
- if (m_acceptOnMatch)
- {
- return FilterDecision.Accept;
- }
- return FilterDecision.Deny;
- }
- return FilterDecision.Neutral;
- }
-
- #endregion
}
}
1.6 +12 -170 logging-log4net/src/Filter/NdcFilter.cs
Index: NdcFilter.cs
===================================================================
RCS file: /home/cvs/logging-log4net/src/Filter/NdcFilter.cs,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- NdcFilter.cs 9 Sep 2004 21:53:13 -0000 1.5
+++ NdcFilter.cs 6 Dec 2004 02:22:05 -0000 1.6
@@ -29,189 +29,31 @@
/// Simple filter to match a string in the <see cref="NDC"/>
/// </summary>
/// <remarks>
+ /// <para>
/// Simple filter to match a string in the <see cref="NDC"/>
+ /// </para>
+ /// <para>
+ /// As the MDC has been replaced with named stacks stored in the
+ /// properties collections the <see cref="PropertyFilter"/> should
+ /// be used instead.
+ /// </para>
/// </remarks>
/// <author>Nicko Cadell</author>
/// <author>Gert Driesen</author>
- public class NdcFilter : FilterSkeleton
+ /*[Obsolete("NdcFilter has been replaced by PropertyFilter")]*/
+ public class NdcFilter : PropertyFilter
{
- #region Member Variables
-
- /// <summary>
- /// Flag to indicate the behavior when we have a match
- /// </summary>
- private bool m_acceptOnMatch = true;
-
- /// <summary>
- /// The string to substring match against the message
- /// </summary>
- private string m_stringToMatch;
-
- /// <summary>
- /// A string regex to match
- /// </summary>
- private string m_stringRegexToMatch;
-
- /// <summary>
- /// A regex object to match (generated from m_stringRegexToMatch)
- /// </summary>
- private Regex m_regexToMatch;
-
- #endregion
-
- #region Constructors
-
/// <summary>
/// Default constructor
/// </summary>
- public NdcFilter()
- {
- }
-
- #endregion
-
- #region Implementation of IOptionHandler
-
- /// <summary>
- /// Initialize and precompile the Regex if required
- /// </summary>
/// <remarks>
/// <para>
- /// This is part of the <see cref="IOptionHandler"/> delayed object
- /// activation scheme. The <see cref="ActivateOptions"/> method must
- /// be called on this object after the configuration properties have
- /// been set. Until <see cref="ActivateOptions"/> is called this
- /// object is in an undefined state and must not be used.
+ /// Sets the <see cref="PropertyFilter.Key"/> to <c>"NDC"</c>.
/// </para>
- /// <para>
- /// If any of the configuration properties are modified then
- /// <see cref="ActivateOptions"/> must be called again.
- /// </para>
- /// </remarks>
- override public void ActivateOptions()
- {
- if (m_stringRegexToMatch != null)
- {
- m_regexToMatch = new Regex(m_stringRegexToMatch, RegexOptions.Compiled);
- }
- }
-
- #endregion
-
- /// <summary>
- /// The <see cref="AcceptOnMatch"/> property is a flag that determines
- /// the behavior when a matching <see cref="Level"/> is found. If the
- /// flag is set to true then the filter will <see cref="FilterDecision.Accept"/> the
- /// logging event, otherwise it will <see cref="FilterDecision.Deny"/> the event.
- /// </summary>
- public bool AcceptOnMatch
- {
- get { return m_acceptOnMatch; }
- set { m_acceptOnMatch = value; }
- }
-
- /// <summary>
- /// The string that will be substring matched against
- /// the rendered message. If the message contains this
- /// string then the filter will match.
- /// </summary>
- public string StringToMatch
- {
- get { return m_stringToMatch; }
- set { m_stringToMatch = value; }
- }
-
- /// <summary>
- /// The regular expression pattern that will be matched against
- /// the rendered message. If the message matches this
- /// pattern then the filter will match.
- /// </summary>
- public string RegexToMatch
- {
- get { return m_stringRegexToMatch; }
- set { m_stringRegexToMatch = value; }
- }
-
- #region Override implementation of FilterSkeleton
-
- /// <summary>
- /// Check if this filter should allow the event to be logged
- /// </summary>
- /// <remarks>
- /// The <see cref="NDC"/> is matched against the <see cref="StringToMatch"/>.
- /// If the <see cref="StringToMatch"/> occurs as a substring within
- /// the message then a match will have occurred. If no match occurs
- /// this function will return <see cref="FilterDecision.Neutral"/>
- /// allowing other filters to check the event. If a match occurs then
- /// the value of <see cref="AcceptOnMatch"/> is checked. If it is
- /// true then <see cref="FilterDecision.Accept"/> is returned otherwise
- /// <see cref="FilterDecision.Deny"/> is returned.
/// </remarks>
- /// <param name="loggingEvent">the event being logged</param>
- /// <returns>see remarks</returns>
- override public FilterDecision Decide(LoggingEvent loggingEvent)
+ public NdcFilter()
{
- if (loggingEvent == null)
- {
- throw new ArgumentNullException("loggingEvent");
- }
-
- string msg = null;
-
- object msgObj = loggingEvent.LookupProperty("NDC");
- if (msgObj is string)
- {
- msg = (string)msgObj;
- }
- else if (msgObj is ThreadContextStack)
- {
- msg = ((ThreadContextStack)msgObj).GetFullMessage();
- }
-
- // Check if we have been setup to filter
- if (msg == null || (m_stringToMatch == null && m_regexToMatch == null))
- {
- // We cannot filter so allow the filter chain
- // to continue processing
- return FilterDecision.Neutral;
- }
-
- // Firstly check if we are matching using a regex
- if (m_regexToMatch != null)
- {
- // Check the regex
- if (m_regexToMatch.Match(msg).Success == false)
- {
- // No match, continue processing
- return FilterDecision.Neutral;
- }
-
- // we've got a match
- if (m_acceptOnMatch)
- {
- return FilterDecision.Accept;
- }
- return FilterDecision.Deny;
- }
- else if (m_stringToMatch != null)
- {
- // Check substring match
- if (msg.IndexOf(m_stringToMatch) == -1)
- {
- // No match, continue processing
- return FilterDecision.Neutral;
- }
-
- // we've got a match
- if (m_acceptOnMatch)
- {
- return FilterDecision.Accept;
- }
- return FilterDecision.Deny;
- }
- return FilterDecision.Neutral;
+ base.Key = "NDC";
}
-
- #endregion
}
}
1.2 +17 -87 logging-log4net/src/Filter/PropertyFilter.cs
Index: PropertyFilter.cs
===================================================================
RCS file: /home/cvs/logging-log4net/src/Filter/PropertyFilter.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- PropertyFilter.cs 9 Sep 2004 21:53:13 -0000 1.1
+++ PropertyFilter.cs 6 Dec 2004 02:22:05 -0000 1.2
@@ -26,37 +26,20 @@
namespace log4net.Filter
{
/// <summary>
- /// Simple filter to match a string in the event properties
+ /// Simple filter to match a string an event property
/// </summary>
/// <remarks>
- /// Simple filter to match a string in the event properties
+ /// <para>
+ /// Simple filter to match a string in the value for a
+ /// specific event property
+ /// </para>
/// </remarks>
/// <author>Nicko Cadell</author>
- public class PropertyFilter : FilterSkeleton
+ public class PropertyFilter : StringMatchFilter
{
#region Member Variables
/// <summary>
- /// Flag to indicate the behavior when we have a match
- /// </summary>
- private bool m_acceptOnMatch = true;
-
- /// <summary>
- /// The string to substring match against the message
- /// </summary>
- private string m_stringToMatch;
-
- /// <summary>
- /// A string regex to match
- /// </summary>
- private string m_stringRegexToMatch;
-
- /// <summary>
- /// A regex object to match (generated from m_stringRegexToMatch)
- /// </summary>
- private Regex m_regexToMatch;
-
- /// <summary>
/// The key to use to lookup the string from the event properties
/// </summary>
private string m_key;
@@ -74,71 +57,16 @@
#endregion
- #region Implementation of IOptionHandler
-
/// <summary>
- /// Initialize and precompile the Regex if required
+ /// The key to lookup in the event properties and then match against.
/// </summary>
/// <remarks>
/// <para>
- /// This is part of the <see cref="IOptionHandler"/> delayed object
- /// activation scheme. The <see cref="ActivateOptions"/> method must
- /// be called on this object after the configuration properties have
- /// been set. Until <see cref="ActivateOptions"/> is called this
- /// object is in an undefined state and must not be used.
- /// </para>
- /// <para>
- /// If any of the configuration properties are modified then
- /// <see cref="ActivateOptions"/> must be called again.
+ /// The key name to use to lookup in the properties map of the
+ /// <see cref="LoggingEvent"/>. The match will be performed against
+ /// the value of this property if it exists.
/// </para>
/// </remarks>
- override public void ActivateOptions()
- {
- if (m_stringRegexToMatch != null)
- {
- m_regexToMatch = new Regex(m_stringRegexToMatch, RegexOptions.Compiled);
- }
- }
-
- #endregion
-
- /// <summary>
- /// The <see cref="AcceptOnMatch"/> property is a flag that determines
- /// the behavior when a matching <see cref="Level"/> is found. If the
- /// flag is set to true then the filter will <see cref="FilterDecision.Accept"/> the
- /// logging event, otherwise it will <see cref="FilterDecision.Deny"/> the event.
- /// </summary>
- public bool AcceptOnMatch
- {
- get { return m_acceptOnMatch; }
- set { m_acceptOnMatch = value; }
- }
-
- /// <summary>
- /// The string that will be substring matched against
- /// the rendered message. If the message contains this
- /// string then the filter will match.
- /// </summary>
- public string StringToMatch
- {
- get { return m_stringToMatch; }
- set { m_stringToMatch = value; }
- }
-
- /// <summary>
- /// The regular expression pattern that will be matched against
- /// the rendered message. If the message matches this
- /// pattern then the filter will match.
- /// </summary>
- public string RegexToMatch
- {
- get { return m_stringRegexToMatch; }
- set { m_stringRegexToMatch = value; }
- }
-
- /// <summary>
- /// The key to lookup in the event properties and then match against.
- /// </summary>
public string Key
{
get { return m_key; }
@@ -150,19 +78,21 @@
/// <summary>
/// Check if this filter should allow the event to be logged
/// </summary>
+ /// <param name="loggingEvent">the event being logged</param>
+ /// <returns>see remarks</returns>
/// <remarks>
+ /// <para>
/// The event property for the <see cref="Key"/> is matched against
- /// the <see cref="StringToMatch"/>.
- /// If the <see cref="StringToMatch"/> occurs as a substring within
+ /// the <see cref="StringMatchFilter.StringToMatch"/>.
+ /// If the <see cref="StringMatchFilter.StringToMatch"/> occurs as a substring within
/// the property value then a match will have occurred. If no match occurs
/// this function will return <see cref="FilterDecision.Neutral"/>
/// allowing other filters to check the event. If a match occurs then
- /// the value of <see cref="AcceptOnMatch"/> is checked. If it is
+ /// the value of <see cref="StringMatchFilter.AcceptOnMatch"/> is checked. If it is
/// true then <see cref="FilterDecision.Accept"/> is returned otherwise
/// <see cref="FilterDecision.Deny"/> is returned.
+ /// </para>
/// </remarks>
- /// <param name="loggingEvent">the event being logged</param>
- /// <returns>see remarks</returns>
override public FilterDecision Decide(LoggingEvent loggingEvent)
{
if (loggingEvent == null)
1.5 +44 -12 logging-log4net/src/Filter/StringMatchFilter.cs
Index: StringMatchFilter.cs
===================================================================
RCS file: /home/cvs/logging-log4net/src/Filter/StringMatchFilter.cs,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- StringMatchFilter.cs 30 May 2004 11:04:08 -0000 1.4
+++ StringMatchFilter.cs 6 Dec 2004 02:22:05 -0000 1.5
@@ -29,7 +29,9 @@
/// Simple filter to match a string in the rendered message
/// </summary>
/// <remarks>
+ /// <para>
/// Simple filter to match a string in the rendered message
+ /// </para>
/// </remarks>
/// <author>Nicko Cadell</author>
/// <author>Gert Driesen</author>
@@ -40,22 +42,22 @@
/// <summary>
/// Flag to indicate the behavior when we have a match
/// </summary>
- private bool m_acceptOnMatch = true;
+ protected bool m_acceptOnMatch = true;
/// <summary>
/// The string to substring match against the message
/// </summary>
- private string m_stringToMatch;
+ protected string m_stringToMatch;
/// <summary>
/// A string regex to match
/// </summary>
- private string m_stringRegexToMatch;
+ protected string m_stringRegexToMatch;
/// <summary>
/// A regex object to match (generated from m_stringRegexToMatch)
/// </summary>
- private Regex m_regexToMatch;
+ protected Regex m_regexToMatch;
#endregion
@@ -99,11 +101,19 @@
#endregion
/// <summary>
+ /// <see cref="FilterDecision.Accept"/> when matching <see cref="StringToMatch"/> or <see cref="RegexToMatch"/>
+ /// </summary>
+ /// <remarks>
+ /// <para>
/// The <see cref="AcceptOnMatch"/> property is a flag that determines
/// the behavior when a matching <see cref="Level"/> is found. If the
/// flag is set to true then the filter will <see cref="FilterDecision.Accept"/> the
- /// logging event, otherwise it will <see cref="FilterDecision.Deny"/> the event.
- /// </summary>
+ /// logging event, otherwise it will <see cref="FilterDecision.Neutral"/> the event.
+ /// </para>
+ /// <para>
+ /// The default is <c>true</c> i.e. to <see cref="FilterDecision.Accept"/> the event.
+ /// </para>
+ /// </remarks>
public bool AcceptOnMatch
{
get { return m_acceptOnMatch; }
@@ -111,10 +121,20 @@
}
/// <summary>
+ /// Sets the static string to match
+ /// </summary>
+ /// <remarks>
+ /// <para>
/// The string that will be substring matched against
/// the rendered message. If the message contains this
- /// string then the filter will match.
- /// </summary>
+ /// string then the filter will match. If a match is found then
+ /// the result depends on the value of <see cref="AcceptOnMatch"/>.
+ /// </para>
+ /// <para>
+ /// One of <see cref="StringToMatch"/> or <see cref="RegexToMatch"/>
+ /// must be specified.
+ /// </para>
+ /// </remarks>
public string StringToMatch
{
get { return m_stringToMatch; }
@@ -122,10 +142,20 @@
}
/// <summary>
+ /// Sets the regular expression to match
+ /// </summary>
+ /// <remarks>
+ /// <para>
/// The regular expression pattern that will be matched against
/// the rendered message. If the message matches this
- /// pattern then the filter will match.
- /// </summary>
+ /// pattern then the filter will match. If a match is found then
+ /// the result depends on the value of <see cref="AcceptOnMatch"/>.
+ /// </para>
+ /// <para>
+ /// One of <see cref="StringToMatch"/> or <see cref="RegexToMatch"/>
+ /// must be specified.
+ /// </para>
+ /// </remarks>
public string RegexToMatch
{
get { return m_stringRegexToMatch; }
@@ -137,7 +167,10 @@
/// <summary>
/// Check if this filter should allow the event to be logged
/// </summary>
+ /// <param name="loggingEvent">the event being logged</param>
+ /// <returns>see remarks</returns>
/// <remarks>
+ /// <para>
/// The rendered message is matched against the <see cref="StringToMatch"/>.
/// If the <see cref="StringToMatch"/> occurs as a substring within
/// the message then a match will have occurred. If no match occurs
@@ -146,9 +179,8 @@
/// the value of <see cref="AcceptOnMatch"/> is checked. If it is
/// true then <see cref="FilterDecision.Accept"/> is returned otherwise
/// <see cref="FilterDecision.Deny"/> is returned.
+ /// </para>
/// </remarks>
- /// <param name="loggingEvent">the event being logged</param>
- /// <returns>see remarks</returns>
override public FilterDecision Decide(LoggingEvent loggingEvent)
{
if (loggingEvent == null)