logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Cheng <chen...@gmail.com>
Subject Re: AdoNetAppender problem.
Date Thu, 11 Jan 2007 19:17:22 GMT
does any one experience of loss log entries when using AdoNetAppender?

I have both RollingFileAppender and AdoNetAppender in one of my application.
>From time to time, there were some of log entries missing in the database
but they were in the log file. The bufferSize is set to 1.

On 1/8/07, bolikdimon <bolikdimon@mail.ru> wrote:
>
>
> I found better way of doing this:
> Here is my config file:
>       <parameter>
>         <parameterName value="@ProcessID" />
>         <dbType value="Int64" />
>         <layout type="log4net.Layout.RawPropertyLayout" >
>           <key value="ProcessID" />
>         </layout>
>       </parameter>
>
> It works !
>
>
>
> Stephen Murtagh wrote:
> >
> > I had a similar problem about a year back, ended up subclassing
> > AdoNetAppenderParameter and overriding the FormatValue method as below:
> >
> >  public class MyAdoNetAppenderParameter : AdoNetAppenderParameter
> >  {
> >   /// <summary>
> >   /// Custom version of FormatValue method which also converts NullText
> >   value (null) to DBNull
> >   /// </summary>
> >   /// <param name="command"></param>
> >   /// <param name="loggingEvent"></param>
> >   public override void FormatValue(System.Data.IDbCommand command,
> >   log4net.Core.LoggingEvent loggingEvent)
> >   {
> >    // Lookup the parameter
> >    IDbDataParameter param =
> >    (IDbDataParameter)command.Parameters[ParameterName];
> >
> >    // Format the value
> >    object formattedValue = Layout.Format(loggingEvent);
> >
> >    // If the value is null then convert to a DBNull
> >    if ((formattedValue == null) || (formattedValue.ToString() ==
> >    SystemInfo.NullText))
> >    {
> >     formattedValue = DBNull.Value;
> >    }
> >
> >    param.Value = formattedValue;
> >   }
> >  }
> >
> > This can be intergrated with any other changes to your existing logging
> > code and only one minor change to the config file - set the type of the
> > parameter to that of your new class above.
> >
> > Hope this helps.
> >
> > Is there a better or recommended way of doing this?
> >
> >
> > -----bolikdimon <bolikdimon@mail.ru> wrote: -----
> >
> >
> > To: log4net-user@logging.apache.org
> > From: bolikdimon <bolikdimon@mail.ru>
> > Date: 01/08/2007 01:02PM
> > Subject: AdoNetAppender problem.
> >
> >
> > Hello. Help me please.
> > I'm using AdoNetAppender. How can I pass NULL value into stored
> procedure
> > ?
> > Here is my code:
> >             ...
> >            ThreadContext.Properties["ProcessID"] = DbNull.Value;
> >            log.Debug(message);
> >
> > Config-file:
> >      <parameter>
> >        <parameterName value="@ProcessID" />
> >        <dbType value="Int64" />
> >        <layout type="log4net.Layout.PatternLayout" value="%X{ProcessID}"
> > />
> >      </parameter>
> >
> > What's wrong ?
> >
> > --
> > View this message in context:
> > http://www.nabble.com/AdoNetAppender-problem.-tf2939176.html#a8217407
> > Sent from the Log4net - Users mailing list archive at Nabble.com.
> >
> >
> >
> >
> *********************************************************************************
> >
> > Disclaimer: This electronic mail, together with any attachments, is for
> > the exclusive and confidential use of the recipient addressee. Any other
> > distribution, use or reproduction without our prior consent is
> > unauthorised and strictly prohibited. If you have received this message
> in
> > error, please delete it immediately and contact the sender directly or
> the
> > Robert Wiseman & Sons Ltd IT Helpdesk on +44 (0)1355 270634. Any views
> or
> > opinions expressed in this message are those of the author and do not
> > necessarily represent those of Robert Wiseman & Sons Ltd or of any of
> its
> > associated companies. No reliance may be placed on this message without
> > written confirmation from an authorised representative of the company.
> >
> > Robert Wiseman & Sons Limited reserves the right to monitor all e-mail
> > communications through its network.
> >
> > This message has been checked for viruses but the recipient is strongly
> > advised to re-scan the message before opening any attachments or
> attached
> > executable files.
> >
> >
> ********************************************************************************
> >
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/AdoNetAppender-problem.-tf2939176.html#a8223361
> Sent from the Log4net - Users mailing list archive at Nabble.com.
>
>

Mime
View raw message