logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Radovan Raszka <ras...@hasam.cz>
Subject RE: Can't get RollingFileAppender to work...
Date Fri, 10 Apr 2015 06:08:29 GMT
Hello.
First of all - you are trying to use nonexisting logger. You define:
<appender name="RollingFile" type="log4net.Appender.RollingFileAppender">

Byt trying to use:
<root>
-->>>	<appender-ref ref="LogglyLogger" >
	    <threshold value="DEBUG" />
	</appender-ref>
</root>

Second - your example can't be compiled - remove void in public void MyLogger(), constructor
has no return type
If you fix these two mistakes,  it should work.
Cheers, Radovan

-----Original Message-----
From: karlkras [mailto:karlkras@yahoo.com] 
Sent: Thursday, April 09, 2015 7:18 PM
To: log4net-user@logging.apache.org
Subject: Can't get RollingFileAppender to work...

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.

Mime
View raw message