logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Georg Jansen <Georg.Jan...@Faktnet.com>
Subject RE: custom fields?
Date Thu, 02 Oct 2008 16:58:41 GMT
Bill,

 

Add your custom columns to one of the properties collections, for example
GlobalContext (or ThreadContext), for example:

 

log4net.GlobalContext.Properties["CustomCol1"] = "My custom column 1 value";

log4net.GlobalContext.Properties["CustomCol2"] = "My custom column 1 value";

 

Then pick up the value in the layout with the %property{propertyName}
syntax, for example:

 

%property{CustomCol1}

 

BR,

Georg

 <http://www.l4ndash.com> http://www.l4ndash.com - Log4Net Dashboard

 

 

From: Bill McCormick [mailto:wpmccormick@gmail.com] 
Sent: 2. oktober 2008 18:39
To: log4net-user
Subject: custom fields?

 

Hello,

Is it possible to add custom fields to log4net. I'd like to be able to do
something like this:

log.InfoFormat("Custom1", "Custom2", "Custom3", "{0}","Message");

and then have an appender look something like:

<layout type="log4net.Layout.

PatternLayout">
  <conversionPattern value="%custom1 %custom2 %custom3 %message%newline" />
</layout>


Thanks,

Bill


Mime
View raw message