logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ron Grabowski <rongrabow...@yahoo.com>
Subject Re: Add or change parameter value dynamicly
Date Fri, 03 Aug 2007 02:33:37 GMT
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@gmail.com>
To: log4net-user@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"
    <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
    <bufferSize value="128" />
      <parameterName value=":rmmetadataid" />
      <dbType value="Int32" />
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="285" />
      <parameterName value=":processtype" />
      <dbType value="Int32" />
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="1" />
      <parameterName value=":log_date" />
      <dbType value="DateTime" />
      <layout type="log4net.Layout.RawTimeStampLayout" />
      <parameterName value=":log_level" />
      <dbType value="String" />
      <size value="50" />
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%level" />
      <parameterName value=":message" />
      <dbType value="String" />
      <size value="4000" />
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%message" />

i add the processID parameter programiticaly like this 

 log4net.Repository.Hierarchy.Hierarchy hierarchy = null;
            log4net.Repository.Hierarchy.Logger logger = null;

            //// Configure root logger
            logger = hierarchy.Root;
            log4net.Appender.AdoNetAppender adoAppender =

            log4net.Appender.AdoNetAppenderParameter processIdParam = new
            processIdParam.ParameterName = ":processid";
            processIdParam.DbType = System.Data.DbType.Int32;
            PatternLayout pl = new PatternLayout();
            RawLayoutConverter rlc = new RawLayoutConverter();
            pl.ConversionPattern = ProcessID.ToString();
            processIdParam.Layout = (IRawLayout)rlc.ConvertFrom(pl);
            hierarchy.Configured = true;
and call xmlconfigurator to configure logging before adding parameter
programiticaly. but it doesn't work. please help to solve this problem...
note that when i add procesis parameter manually to config file it all works
View this message in context: http://www.nabble.com/Add-or-change-parameter-value-dynamicly-tf4192651.html#a11923011
Sent from the Log4net - Users mailing list archive at Nabble.com.

View raw message