I am creating SMPTAppender to send email log files when an error occurs in the production code. There are several machines, such as test machines, which are local, where I do not want the sent email to be sent.
I tried using the COMPUTERNAME environment variable in the properties file, but this did not work:
<filter type="log4net.Filter.PropertyFilter">
<Key value="COMPUTERNAME" />
<StringToMatch value="myComputerName" />
<Accept value="false" />
</filter>
I used the computer_name in the appender file as follows:
<file value="${HOMEDRIVE}\\loggingDirectory\\AppLogFile.${COMPUTERNAME}.log" />
This also did not work (and I did not expect this):
<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 are welcome.
source
share