in src/log4net/Filter/PropertyFilter.cs [97:161]
public override FilterDecision Decide(LoggingEvent loggingEvent)
{
if (loggingEvent == null)
{
throw new ArgumentNullException("loggingEvent");
}
// Check if we have a key to lookup the event property 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;
}