RE: ADONetAppender

Nicko Cadell <[email protected]> Mon, 19 Jan 2004 17:36:52 -0000
Newsgroups gmane.comp.windows.dotnet.log4net.user
Message-ID <[email protected]>
Sloan,

My mistake, the RawPropertyLayout class was added to cvs after the last
release. You can do the same thing like this:

<param name="Layout" type="log4net.Layout.PatternLayout">
  <param name="ConversionPattern" value="%P{MyField}" />
</param>

The main drawback to this method is that it will only work for properties
that are strings. If you need to pass something like a DateTime you will
need to convert it to a sql friendly string representation and store that in
the properties map instead of the DateTime object.

Nicko


> Nicko,
> 
> According to your example there is a 
> log4net.Layout.RawPropertyLayout, but it doesn't exist anywhere...
> 
> What class should I use then?
> 
> Thanks!
> --
> Sloan
> 
> ----- Original Message ----- 
> From: "Nicko Cadell" <[email protected]>
> To: "'Sloan Seaman'" <[email protected]>
> Sent: Monday, January 19, 2004 9:49 AM
> Subject: RE: [Log4net-users] ADONetAppender
> 
> 
> > The ILog interface is actually also an extension, it's just the 
> > default
> one
> > that ships with the library. The LogManager is the factory that 
> > creates
> the
> > ILog objects.
> >
> > The event id extension has to provide a different factory
> EventIDLogManager
> > to create its loggers. The benefit of using extensions is 
> that log4net 
> > supports using multiple extensions simultaneously. It is just up to 
> > the calling code to select the correct factory.
> >
> > If you have any questions then drop me an email,
> >
> > Nicko
> >
> > > -----Original Message-----
> > > From: Sloan Seaman [mailto:[email protected]]
> > > Sent: 19 January 2004 13:50
> > > To: Nicko Cadell; [email protected]
> > > Subject: Re: [Log4net-users] ADONetAppender
> > >
> > >
> > > I assumed I would have to write a wrapper, so at least I got that 
> > > step correct ;)
> > >
> > > Thanks for the example. I was wondering how to best pull off the 
> > > creating of the wrapper object.
> > >
> > > I'll try it this week and see if I have any question.
> > >
> > > Thanks!
> > >
> > > --
> > > Sloan
> > >
> > > ----- Original Message -----
> > > From: "Nicko Cadell" <[email protected]>
> > > To: "'Sloan Seaman'" <[email protected]>;
> > > <[email protected]>
> > > Sent: Monday, January 19, 2004 8:39 AM
> > > Subject: RE: [Log4net-users] ADONetAppender
> > >
> > >
> > > > Sloan,
> > > >
> > > > There are two distinct steps here:
> > > >
> > > > 1 Get the additional logging fields into log4net
> > > > 2 Writing the additional fields into the database
> > > >
> > > >
> > > > 1 Get the additional logging fields into log4net
> > > >
> > > > To do this properly you will need to write what is called an 
> > > > extension.
> > > This
> > > > is a wrapper around log4net that exposes a different interface. 
> > > > The best example for you is the EventID extension (see 
> > > > log4net\extensions\net\1.0\log4net.Ext.EventID). This
> > > extension allows
> > > > you to pass an event id to log4net. The extension stores
> > > the event id
> > > > in an event specific property map. You should put your 
> additional 
> > > > fields into
> > > this
> > > > map.
> > > >
> > > >
> > > > 2 Writing the additional fields into the database
> > > >
> > > > The ADONetAppender can be configured to write any named
> > > property into
> > > > the database using the following configuration for the 
> parameter:
> > > >
> > > > <param name="Parameter">
> > > >   <param name="ParameterName" value="@log_my_field" />
> > > >   <param name="DbType" value="String" />
> > > >   <param name="Size" value="255" />
> > > >   <param name="Layout" type="log4net.Layout.RawPropertyLayout">
> > > >     <param name="Key" value="MyField" />
> > > >   </param>
> > > > </param>
> > > >
> > > > The value of the property may be any object type that is
> > > accepted by
> > > > the IDbDataParameter for the DbType specified.
> > > >
> > > > Nicko
> > > >
> > > >
> > > > > -----Original Message-----
> > > > > From: Sloan Seaman [mailto:[email protected]]
> > > > > Sent: 16 January 2004 15:48
> > > > > To: [email protected]
> > > > > Subject: [Log4net-users] ADONetAppender
> > > > >
> > > > >
> > > > > I've got an app that I wish to have log to a SQL Server 
> > > > > instance.
> > > > >
> > > > > Using the examples in the docs it works fine.   I need to be
> > > > > able to record
> > > > > some other information into seperate db fields though.
> > > > >
> > > > > Basically I'm rewriting an existing app and want to use
> > > log4net but
> > > > > the current app has fields like "method" in the log table.
> > > > >
> > > > > The current app calls the proprietary logging system and
> > > passes the
> > > > > method name along with the description string.
> > > > >
> > > > > How would I pull this off in log4net?
> > > > >
> > > > > Thanks!
> > > > >
> > > > > --
> > > > > Sloan
> > > > >
> > > > >
> > > > > ______________________________________________________________
> > > > > __________
> > > > > This email has been scanned for all viruses by the
> > > MessageLabs Email
> > > > > Security System. For more information on a proactive
> > > email security
> > > > > service working around the clock, around the globe, visit 
> > > > > http://www.messagelabs.com 
> > > > > ______________________________________________________________
> > > > > __________
> > > > >
> > > > >
> > > > > -------------------------------------------------------
> > > > > The SF.Net email is sponsored by EclipseCon 2004 Premiere 
> > > > > Conference on Open Tools Development and Integration See the 
> > > > > breadth of Eclipse activity. February 3-5 in Anaheim, CA. 
> > > > > http://www.eclipsecon.org/osdn 
> > > > > _______________________________________________
> > > > > Log4net-users mailing list [email protected]
> > > > > https://lists.sourceforge.net/lists/listinfo/log4net-users
> > > > >
> > > >
> > > >
> > > > -------------------------------------------------------
> > > > The SF.Net email is sponsored by EclipseCon 2004
> > > > Premiere Conference on Open Tools Development and
> > > Integration See the
> > > > breadth of Eclipse activity. February 3-5 in Anaheim, CA. 
> > > > http://www.eclipsecon.org/osdn 
> > > > _______________________________________________
> > > > Log4net-users mailing list [email protected]
> > > > https://lists.sourceforge.net/lists/listinfo/log4net-users
> > >
> > >
> > > ______________________________________________________________
> > > __________
> > > This email has been scanned for all viruses by the 
> MessageLabs Email 
> > > Security System. For more information on a proactive 
> email security 
> > > service working around the clock, around the globe, visit 
> > > http://www.messagelabs.com 
> > > ______________________________________________________________
> > > __________
> > >
> 
> 
> ______________________________________________________________
> __________
> This email has been scanned for all viruses by the 
> MessageLabs Email Security System. For more information on a 
> proactive email security service working around the clock, 
> around the globe, visit http://www.messagelabs.com 
> ______________________________________________________________
> __________
> 


-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn