I am setting up an SMPTAppender to email log files when there is an error in production code. There are some machines, such as test machines that are local, where I don't want the email sent.
I tried to use the environment variable COMPUTERNAME in a propertyfilter, but this didn't work:
<filter type="log4net.Filter.PropertyFilter">
<Key value="COMPUTERNAME" />
<StringToMatch value="myComputerName" />
<Accept value="false" />
</filter>
I have used ComputerName in a file appender like this:
<file value="${HOMEDRIVE}\\loggingDirectory\\AppLogFile.${COMPUTERNAME}.log" />
This also didn't work (nor did I expect it to):
<filter type="log4net.Filter.PropertyFilter">
<Key value="${COMPUTERNAME}" />
<StringToMatch value="myComputerName" />
<Accept value="false" />
</filter>
Is there a way to use environment variables in a property filter? Other suggestions welcome.