Does anyone know how to dump environment name in log4net?
e.g.
<c开发者_开发问答onversionPattern value="%date{ISO8601} Server:%property{log4net:HostName} [%-5level] %m" />
This will give computer name.
Not sure what do you mean by "environment name", but with log4net contexts you can log anything: logged on user, ip address if dynamic etc.
Not sure how to add it to the e-mail subject, but in the body pattern would be:
<conversionPattern value="%date{ISO8601} Server:%property{environment} [%-5level] %m" />
after you init log4net, call this:
log4net.GlobalContext.Properties["environment"] =
Environment.GetEnvironmentVariables("EnvironmentName")+"AppName";
It seems you can just add $(COMPUTERNAME) to your conversionPattern. If it is the computername you were looking for?
精彩评论