RE: Log the machine name.

Nicko Cadell <[email protected]> Tue, 3 Feb 2004 15:25:37 -0000
Newsgroups gmane.comp.windows.dotnet.log4net.user
Message-ID <[email protected]>
Alex,

Yes we have considered adding a diagnostic map that is shared across
threads. There are two ways to do this, one is to add a new map, new storage
slots on the event and new pattern converters. The alternative is to weave
the map into one of the two existing maps (MDC and Properties).

When the event is remoted across a machine boundary we would need to be
careful to specify the behaviour of the global map, i.e. would the original
values from the source machine be transferred with the object like the MDC
and Properties.

Also the loggers are organised into Repositories (most people only have one)
should be have a map for each repository as well as at a global level.

I am conscious of adding too much complexity and have not yet found the
right balance for this feature.

Nicko

> -----Original Message-----
> From: Alex Ben-Ari [mailto:[email protected]] 
> Sent: 03 February 2004 15:03
> To: [email protected]
> Subject: RE: [Log4net-users] Log the machine name.
> 
> 
> 
> 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 
> _______________________________________________
> 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