You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4net-user@logging.apache.org by David Elliott <we...@hotmail.com> on 2004/11/09 13:42:16 UTC

Adding a new field to the layout

Is there an example of adding new fields to the layout?

I would like to add fields such as internal error number,
application name, module name, etc.

Thanks,
Dave

_________________________________________________________________
On the road to retirement? Check out MSN Life Events for advice on how to 
get there! http://lifeevents.msn.com/category.aspx?cid=Retirement


Re: Adding a new field to the layout

Posted by Tom Willis <to...@gmail.com>.
I got this working this weekend. It's pretty slick. 


in your code.....

...
log4net.MDC.Set("AnotherVariable", AnotherVariableData); 
...
ILog l  = LogManager.GetLogger("MyLogger");
l.Error(MyMessage,MyException);
...


In your config ...

		<layout type="log4net.Layout.PatternLayout">
			<conversionPattern value="%X{AnotherVariable}" />
		</layout>


The Key components are the "%X{...}" and the "log4net.MDC.Set"

Hope that helps.

-- 
Thomas G. Willis
http://paperbackmusic.net

On Tue, 09 Nov 2004 07:42:16 -0500, David Elliott
<we...@hotmail.com> wrote:
> Is there an example of adding new fields to the layout?
> 
> I would like to add fields such as internal error number,
> application name, module name, etc.
> 
> Thanks,
> Dave
> 
> _________________________________________________________________
> On the road to retirement? Check out MSN Life Events for advice on how to
> get there! http://lifeevents.msn.com/category.aspx?cid=Retirement
> 
>