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

Hello,

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

Here is one of my extra parameters defined:

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

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.

Regards,

Cankut

Mime
View raw message