in src/log4net/Filter/StringMatchFilter.cs [189:241]
public override FilterDecision Decide(LoggingEvent loggingEvent)
{
if (loggingEvent == null)
{
throw new ArgumentNullException("loggingEvent");
}
string msg = loggingEvent.RenderedMessage;
// 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;
}