tags:

views:

102

answers:

2

Does anyone know how to dump environment name in log4net?

e.g.

<conversionPattern value="%date{ISO8601} Server:%property{log4net:HostName} [%-5level] %m" />

This will give computer name.

+1  A: 

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";
Al Bundy
A: 

Whenever we send any error email, in our subject we put (computer name + application name) e.g. (Computer21TwitterApplicaiton)

In the computer, i have set environment variable i.e Development. So now i want to have subject value as (Environment Name + applicaiton Name) e.g (DevelopmentTwitterApplication)

sanjeev40084
check my updated answer, you can do it with log4net contexts.
Al Bundy