RE: Log the machine name.

"Alex Ben-Ari" <[email protected]> Tue, 3 Feb 2004 16:02:41 +0100
Newsgroups gmane.comp.windows.dotnet.log4net.user
Message-ID <[email protected]>
Is there a plan to provide a mechanism similar to MDC that will be
available to all threads. In some cases, such as the machine name
example here, this can be quite useful. 

Alex. 
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Nicko
Cadell
Sent: Tuesday, February 03, 2004 2:00 PM
To: '[email protected]'; [email protected]
Subject: RE: [Log4net-users] Log the machine name.

Jeff,

There isn't a conversion pattern for the machine name but there are a
number
of ways of doing this depending on your situation.

If you are using the Remoting, SMTP, SmtpPickupDir or Udp appenders then
the
host name is stored in an event property.

If you are using 1.2.0 up to beta7 then the property is called
"hostname" if
you are using 1.2.0 beta8 then it is "log4net:HostName".

You can use the %P{log4net:HostName} pattern to read this value.


If you are not using one of these appenders you will need to manually
pass
the hostname into log4net. The best place to store it is in the mapped
diagnostic context, MDC. This is a thread local map of values. You can
do
this:

MDC.Set("hostname", Environment.MachineName);

This must be done for each thread that calls into log4net.

Use the %X{hostname} pattern to read the value.

Cheers,

Nicko

> -----Original Message-----
> From: Jeff Mabey [mailto:[email protected]] 
> Sent: 30 January 2004 15:30
> To: [email protected]
> Subject: [Log4net-users] Log the machine name.
> 
> 
> I am using log4net and would like to start logging the 
> machine name.  I can't find anything about a conversion 
> pattern that will give me the machine name.  If anyone can 
> help me out with this I would really appreciate it.  Thanks.
> 
>  
> 
> 


-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
_______________________________________________
Log4net-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/log4net-users



-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn