in src/log4net/Filter/StringMatchFilter.cs [132:179]
public override FilterDecision Decide(LoggingEvent loggingEvent)
{
string? msg = loggingEvent.EnsureNotNull().RenderedMessage;
// Check if we have been setup to filter
if (msg is null || (StringToMatch is null && m_regexToMatch is 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 is not null)
{
// Check the regex
if (m_regexToMatch.Match(msg).Success == false)
{
// No match, continue processing
return FilterDecision.Neutral;
}
// we've got a match
if (AcceptOnMatch)
{
return FilterDecision.Accept;
}
return FilterDecision.Deny;
}
else if (StringToMatch is not null)
{
// Check substring match
if (msg.IndexOf(StringToMatch) == -1)
{
// No match, continue processing
return FilterDecision.Neutral;
}
// we've got a match
if (AcceptOnMatch)
{
return FilterDecision.Accept;
}
return FilterDecision.Deny;
}
return FilterDecision.Neutral;
}