> -----Original Message----- > From: tinhuty he [mailto:[EMAIL PROTECTED] > Sent: 05 May 2006 19:18 > To: [email protected] > Subject: couple questions > > I am pretty new to log4net, just started using it weeks ago. > It works great. > I have a couple questions: > > 1. AdoNetAppender: all examples I could find are using insert > statement which is not possible in my case, could someone > point me some examples that using stored-procedures?
Follow the examples at: http://logging.apache.org/log4net/release/config-examples.html Make the following changes: <commandType value="StoredProcedure "/> <commandText value="name of your stored procedure "/> > 2. custom level: custom level is supported in new release but > I still confused in how to use it. for example if I want to > add a TRACE level between FATAL and OFF, what should I put in > config file and how should I log TRACE information in my program? Probably best to have a look at extensions\net\1.0\log4net.Ext.Trace in the log4net download, and the example examples\net\1.0\Extensibility\TraceLogApp that demonstrates using the Trace API. > 3. custom fields: how do I add custom fields dynamically? Custom fields are set via properties on the logging event. These properties can be set directly on the logging event and are therefore scoped to a single log, or they can be specified on the current thread and are inherited by all logs mode on the thread. To set properties on the thread use the ThreadContext.Properties, or globally on the GlobalContext.Properties. To set properties on individual LoggingEvents you will need to write a helper method or an extension. For example see the extensions\net\1.0\log4net.Ext.EventID extension. > in addition, since I am going to use database as storage, how > can I add multiple custom fields into one databse field? the > reason is that if I decide to add new custom field later I > don't want to change the database structure. When specifying the layout for a column you can use the PatternLayout to generate a string by combining several different properties: <parameter> <parameterName value="@extradata" /> <dbType value="String" /> <size value="255" /> <layout type="log4net.Layout.PatternLayout"> <conversionPattern value="%property{prop1}|%property{prop2}" /> </layout> </parameter> Or you can use a stored procedure, pass it each property as a separate argument and then combine the values into a single column in the stored procedure. > 4. Large object: what is the relative better way to log large > objects such as DataTable, XmlNode or an Array of custom > object? how do you log 2d-array or 3d-array? If you have performance considerations you may be best served by writing a custom appender to your requirements. The AdoNetAppender is designed to be flexible and DB neutral. Have a look at the simple FastDbAppender in the examples in the log4net download: examples\net\1.0\Appenders\SampleAppendersApp\cs\src\Appender Cheers, Nicko
