Hello again. So I'm trying to configure a RollingFileAppender logger to work
against a custom level. However, when I call the custom level no file with
content is created/produced.
The xml configuration looks like this:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
        <configSections>
                <section name="log4net"
type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"
requirePermission="false" />
        </configSections>
        <log4net debug="True">
                <level>
                        <name value="AUDIT" />
                        <value value="80000" />
                </level>
                <root>
                        <appender-ref ref="LogglyLogger" >
                                <threshold value="DEBUG" />
                        </appender-ref>
                </root>
                <logger name="EventLogger" additivity="False">
                        <level value="ERROR"/>
                </logger>
                <logger name="RollingFile" additivity="False">
                        <level value="AUDIT"/>
                </logger>
                
                <appender name="RollingFile" 
type="log4net.Appender.RollingFileAppender">
                        <file value="c:\logs\connector\Connector.log" />
                        <appendToFile value="true" />
                        <datePattern value="yyyyMMdd" />
                        <rollingStyle value="Date" />
                        <maxSizeRollBackups value="30"/>
                        <staticLogFileName value="true" />
                        <lockingModel 
type="log4net.Appender.FileAppender+MinimalLock" />
                        <layout type="log4net.Layout.PatternLayout">
                                <conversionPattern value="%-5p %d [%thread] 
%5rms %-22.22c{1} %-18.18M -
%m%n" />
                        </layout>
                </appender>

...

the C# code looks like this:

public class MyLogger
{
                static readonly log4net.Core.Level auditLevel = new
log4net.Core.Level(80000, "Audit");
                private static ILog _logger;

                public void MyLogger()
                {
                        string logFilePath = 
Path.Combine(AppDomain.CurrentDomain.BaseDirectory,
"Config\\Logging.config");
                        FileInfo finfo = new FileInfo(logFilePath);
                        log4net.Core.Level auditLevel = new 
log4net.Core.Level(80000, "Audit");
                        
log4net.LogManager.GetRepository().LevelMap.Add(auditLevel);
                        log4net.Config.XmlConfigurator.ConfigureAndWatch(finfo);
                        _logger = 
LogManager.GetLogger(typeof(WAConnectorLogger));
                }

                public void Audit(string message)
                {
                
_logger.Logger.Log(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType,
                                auditLevel, message, null);
                }


but when I call this method, no log is produced. Any ideas what I'm doing
wrong here?
It all appears to proceed without error so I'm assuming something in my
configuration isn't quite right.
Other appenders are working as hoped, so there's no problem loading the
log4net xml file.

thanks!
            






--
View this message in context: 
http://apache-logging.6191.n7.nabble.com/Can-t-get-RollingFileAppender-to-work-tp54533.html
Sent from the Log4net - Users mailing list archive at Nabble.com.

Reply via email to