I'm having trouble with configuring a StringMatchFilter to match a
string in a message with newlines. I want to skip some messages and I
have added a filter like this and it works.
<filter type="log4net.Filter.StringMatchFilter">
<param name="AcceptOnMatch" value="false" />
<stringToMatch value="Unexpected exception in SocketThreadWorker" />
</filter>
But if I change the stringToMatch to "An existing connection was
forcibly closed by the remote host" which occurs on the second row of
the message the filter does not work. Is it because of the newline in
the message or am I doing anything wrong here?
A typical message can look like this:
------ Example message ----------------------------
2011-05-04 16:22:24,078 [Client (connected from "127.0.0.1:4076" at 16:22)] ERROR - Unexpected exception in SocketThreadWorker System.Net.Sockets.SocketException:
An existing connection was forcibly closed by the remote host at System.Net.Sockets.Socket.EndReceive(IAsyncResult asyncResult)
------ End example message ---------------------------
"Unexpected exception in SocketThreadWorker" is on the first row of the message and "An existing connection was forcibly closed" is on the second row.
Edit
The appender looks like this:
<appender name="SmtpAppender" type="log4net.Appender.SmtpAppender">
<filter type="log4net.Filter.StringMatchFilter">
<param name="AcceptOnMatch" value="false" />
<stringToMatch value="An existing connection was forcibly closed by the remote host" />
</filter>
<to value="..." />
<from value="..." />
<subject value="[.