You could store the value of CustomerID inside a context such as
ThreadContext:

 log4net.ThreadContext.Properties["CustomerID"] = customerId;

Or you could write your own logger:

http://tinyurl.com/b2lxq
http://www.mail-archive.com/log4net-user%40logging.apache.org/msg01993.html

that has overloads for passing in a CustomerID:

 log.Info(customerId, "Hello World");

This is how the parameter node would retrieve the value:

 <conversionPattern value="%property{CustomerID}" />

This page shows all the available patterns:

http://tinyurl.com/e3nd3
http://logging.apache.org/log4net/release/sdk/log4net.Layout.PatternLayout.html

--- "Smith, Johnathon (KEYPEOPLE RESOURCES INC)"
<[EMAIL PROTECTED]> wrote:

> I am new to Log4net, so forgive me if this has been answered, but I
> could not find an answer to my question in the documentation or
> mailing
> lists.
> 
> I saw one post in the mailing list that had custom parameters for the
> AdoNetLogger and I want to do the same thing.  For example, every
> sample
> I see looks something like the sample I copied below.  But, if I
> wanted
> my own custom parameter such as CustomerID, I would create a
> parameter
> like so:
>       <parameter>
>               <parameterName value="@CustID" />
>               <dbType value="String" />
>               <size value="255" />
>               <layout type="log4net.Layout.PatternLayout">
>                       <conversionPattern
> value="%I_DONT_KNOW_WHAT_GOES_HERE" />
>               </layout>
>       </parameter>
> ... and I would change the database to add the column and change the
> insert statement accordingly.  All that is fine.
> 
> So, finally the question, how do get the appender to know what the
> CustomerID is?  How do I get it to pass the customer id to the
> appender?
> Could someone give me a sample of how to get something other than the
> basic properties such as thread, log level, or message?  Or better
> yet,
> if this is documented somewhere, could you point me to it?
> 
> Thanks for any help,
  • Custom parameters Smith, Johnathon \(KEYPEOPLE RESOURCES INC\)
    • Re: Custom parameters Ron Grabowski

Reply via email to