Hi
What I'm trying to do is to include new field (column) in Sql DB, with some additional business related information.
I need this optional info (parameter) in NEW column for fastest browsing and searching.
Idea is to call log from application with new parameter:
log.Info("My message","Some business data");
// or log.Info("My message", ex, "Some business data"); // with Exception
I'm already using custom wrapper for log4net, so I easily overloaded Info function:
public void Info(object message, Exception ex, object additional)
{
using (log4net.LogicalThreadContext.Stacks["additional"].Push(additional.ToString()))
{
this.Logger.Logger.Log
(
_declaringType,
log4net.Core.Level.Info,
message,
ex);
}
}
and I put new parameter in SQLAdoAppender (in config file):
<parameter>
<parameterName value="@Additional" />
<dbType value="String" />
<size value="1024" />
<layout type="
log4net.Layout.PatternLayout">
<conversionPattern value="%property" />
</layout>
</parameter>
and this is working (almost) fine.
My questions are:
1. Is there any better (fastest) way for doing this?
2. My additional parameter is strictly related to called logging event. Would I have on this way interference with other logs?
3. How to get only my additional info from property? I tried this, but it's not working:
<conversionPattern value="%property{additional}" />
4. when I make some error in configuration file (like one above) and then correct it, logging won't work until I restart my web application?!
Thanks, Mario
PS I'm using log4net-1.2.10 in my ASP.NET 2.0 application
- Best way for inserting additional message in log? puska
