Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

log4Net XmlHierarchyConfigurator

Tags:

c#

log4net

Am using Log4Net in my code,it start throwing this weird exception when my process run.

Here is my Appconfig for Log4Net,still am not sure what am missing here

It throws like

log4net:Error XmlHierarchyConfigurator : cannot find property[maxSizeRollBackups] to set object on [log4net.Appender.FileAppender].

Config:

<appender name="ErrorAppender" type="log4net.Appender.FileAppender,log4net">
        <appendToFile value="true" />
        <maxSizeRollBackups value="30" />
        <maximumFileSize value="5MB" />
        <rollingStyle value="Size" />
        <staticLogFileName value="false" />
        <lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
        <file value="C:\Error.log"/>
        <param name="AppendToFile" value="true"/>
        <filter type="log4net.Filter.LevelRangeFilter">
            <param name="LevelMin" value="ERROR"/>
            <param name="LevelMax" value="ERROR"/>
        </filter>
        <layout type="log4net.Layout.PatternLayout">
            <param name="ConversionPattern" value="%d [%t] %-2p %c %method - %m%n"/>
        </layout>
    </appender>
like image 355
Usher Avatar asked Mar 01 '12 02:03

Usher


People also ask

What is rolling file Appender in log4net?

"When set to Once the log file will be rolled when the appender is configured. This effectively means that the log file can be rolled once per program execution. So, when you set your RollingFileAppender to "once", then every time you execute your program, a new log file will be created.

Where do I put log4net in web config?

Add log4net in config file config and enter the following details. Add a class Log. cs in the Utilities folder. Now, in the constructor of this class, instantiate logs for monitoring and debugger loggers.

How do I enable log4net logging?

If you are using a separate configuration file for log4net, do this: after following all the other setup instructions, make sure that u right click on the file in the visual studio solution explorer, select properties, expand the "Advanced" option group, set the "Copy To Output Directory" value as "Copy always".


1 Answers

Change log4net.Appender.FileAppender to log4net.Appender.RollingFileAppender.

<appender name="ErrorAppender" type="log4net.Appender.RollingFileAppender,log4net"> 
like image 101
Min Min Avatar answered Oct 04 '22 03:10

Min Min