0 Comments

If you use a Log4Net renderer in you’re App.config, you might get the error:

Error: log4net:ERROR XmlHierarchyConfigurator: Cannot find Property [renderer] to set object on [log4net.Repository.Hierarchy.RootLogger]
log4net:ERROR XmlHierarchyConfigurator: Cannot find Property [renderer] to set object on [log4net.Repository.Hierarchy.RootLogger]

 

Solution

Place the <renderer> tag not in the <root> tag, but in the <log4net> tag.

 

App.config

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <configSections>
        <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821" />
    </configSections>
    <log4net>
        <appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender">
            <layout type="log4net.Layout.PatternLayout">
                <conversionPattern value="%type.%method() %message%newline" />
            </layout>
        </appender>
        <appender name="EventLogAppender" type="log4net.Appender.EventLogAppender">
            <param name="LogName" value="Application" />
            <applicationName value="Ada.Cdf.Test" />
            <layout type="log4net.Layout.PatternLayout">
                <conversionPattern value="%type.%method()%newline%newline%message%newline" />
            </layout>
        </appender>
        <renderer renderingClass="Ada.Cdf.Logging.ExceptionRenderer, Ada.Cdf" renderedClass="System.Exception" />
        <root>
            <level value="ALL" />
            <appender-ref ref="EventLogAppender" />
            <appender-ref ref="ConsoleAppender" />
        </root>
    </log4net>
</configuration>

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Related Posts