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: Getting AdoNetAppender parameters using Log4Net API
Date Fri, 19 Jun 2009 21:00:16 GMT
Surprisingly the parameters collection isn't exposed publicly so you'd have to extend the built-in
AdoNetAppender and expose them:

public class AdoNetAppender2 : AdoNetAppender
    public AdoNetAppenderParameter[] GetParameters()
        return m_parameters.Cast<AdoNetAppenderParameter>().ToArray();

Then you can ask the repository for all the AdoNetAppender2 appenders and inspect their values:

var repository = LogManager.GetRepository();
foreach (var appender in repository.GetAppenders())
    var adoNetAppender = appender as AdoNetAppender2;
    if (adoNetAppender != null)
        foreach (var parameter in adoNetAppender.GetParameters())
            // parameter.ParameterName;

From: Cankut Eskin <cankuteskin@gmail.com>
To: Log4NET User <log4net-user@logging.apache.org>
Sent: Friday, June 19, 2009 1:13:13 PM
Subject: Getting AdoNetAppender parameters using Log4Net API


I've defined some extra parameters for AdoNetAppender in log4net config file. Everything works

Here is one of my extra parameters defined:

      <parameterName value="@cachetid"/>
      <dbType value="String"/>
      <size value="36"/>
      <layout type="log4net.Layout.RawPropertyLayout">
        <key value="CachetID"/>

I wonder if there is some way in Log4Net API to get information about the parameters defined
for AdoNetAppender in the config file.

Any help will be appreciated.



View raw message