Ron Grabowski | 3 Aug 04:33 2007
Picon

Re: Add or change parameter value dynamicly

Is your ProcessID a special variable that isn't available during startup or do you just want to include the
%processid pattern?

----- Original Message ----
From: arsenmkrt <mkrtchyan.arsen <at> gmail.com>
To: log4net-user <at> logging.apache.org
Sent: Tuesday, July 31, 2007 8:16:43 AM
Subject: Add or change parameter value dynamicly

Hello. I have a table T_Audit where i want to write my log messages in oracle
db. it has a field processid that i want to put dynamically its the
identifier of the process that is doing log not the real process just the id
of process table from my database so i decide to write my appender like this 

 <appender name="AdoNetAppender_Oracle"
type="log4net.Appender.AdoNetAppender">
    <connectionType value="System.Data.OracleClient.OracleConnection,
System.Data.OracleClient, Version=1.0.3300.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089" />
    <connectionString value="my connection string" />
    <commandText value="INSERT INTO T_AUDIT
(LOG_ID,RM_METADATA_ID,PROCESS_ID,PROCESS_TYPE,LOG_DATE,SEVERITY,LOG_MESSAGE)
VALUES
(SEQ_AUDIT.NEXTVAL,:rmmetadataid,:processid,:processtype,:log_date,:log_level,:message)"
/>
    <bufferSize value="128" />
    <parameter>
      <parameterName value=":rmmetadataid" />
      <dbType value="Int32" />
      <layout type="log4net.Layout.PatternLayout">
(Continue reading)

arsenmkrt | 3 Aug 06:58 2007
Picon

Re: Add or change parameter value dynamicly


OK i found the solution i just use mdc . I wrote parametr
<parameter>
      <parameterName value=":processid" />
      <dbType value="Int32" />
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%X{prid}" />
      </layout>
</parameter>
And set the value from my brogram like this
public void SetProcessID(int ProcessID)
{
      MDC.Set("prid", ProcessID.ToString());
}
I found that here

http://weblogs.asp.net/drnetjes/archive/2005/02/16/374780.aspx

Thanks for help.

Ron Grabowski wrote:
> 
> Is your ProcessID a special variable that isn't available during startup
> or do you just want to include the %processid pattern?
> 
> ----- Original Message ----
> From: arsenmkrt <mkrtchyan.arsen <at> gmail.com>
> To: log4net-user <at> logging.apache.org
> Sent: Tuesday, July 31, 2007 8:16:43 AM
> Subject: Add or change parameter value dynamicly
(Continue reading)


Gmane