Thanks for the rapid replies!

I downloaded the 1.2.9, dropped in the precompiled debug dll and reset the 
references. (Also changed to XMLConfigurator).

With no other changes, I found that my secondary class is now logging 
correctly, 
but my primary form is now failing when I test for variables "isDebugEnabled" 
and 
"isInfoEnabled" before logging. (These were testing positive before).

public class Form1 : System.Windows.Forms.Form  {
        private static readonly log4net.ILog log = 
log4net.LogManager.GetLogger(typeof(Form1));
        private static readonly bool isDebugEnabled = log.IsDebugEnabled;
        private static readonly bool isInfoEnabled = log.IsInfoEnabled;
}

Any ideas on this?

Thanks,
Mark Stewart


-----Original Message-----
From: Nicko Cadell [mailto:[EMAIL PROTECTED]
Sent: Friday, June 03, 2005 7:30 AM
To: Log4NET User
Subject: RE: File Access Error with RollingFileAppender


Mark,

The <lockingModel> is only supported in log4net 1.2.9 and above. In
1.2.0 Beta 8 the output file is being locked exclusively by the first
appender to be configured. Can you try upgrading to 1.2.9 which has
support for the file appender locking models.

Cheers,

Nicko

> -----Original Message-----
> From: Stewart, Mark (GE Consumer Finance, consultant) 
> [mailto:[EMAIL PROTECTED] 
> Sent: 03 June 2005 14:55
> To: log4net-user@logging.apache.org
> Subject: File Access Error with RollingFileAppender
> 
> 
> I am having problems with the log4net in a small test project 
> (Using VS.NET 2003, and log4net (1.2.0 Beta 8)).  It works 
> fine when I use the ConsoleAppender, but fails to log some 
> messages with the RollingFileAppender.
> 
> I have a simple log4net test solution with a primary project 
> and a library project with a simple class and log method.
> Both projects call log4net.Config.DOMConfigurator.Configure() 
> on startup, and set the class-level variables:
>               
>   private static readonly log4net.ILog log = 
> log4net.LogManager.GetLogger(typeof(TestClass));
>   private static readonly bool isDebugEnabled = log.IsDebugEnabled;
>   private static readonly bool isInfoEnabled = 
> log.IsInfoEnabled;      
>  
> The primary project logs fine, but the library class instance 
> fails to log to the file when instantiated and called, and I 
> get the following trace output:
> 
> log4net: FileAppender: Opening file for writing 
> [C:\Myfiles\MyProjects\Log4NetTest\LogTest.log] append [True] 
> log4net:ERROR RollingFileAppenderOpenFile(,True) call failed.
> System.IO.IOException: The process cannot access the file 
> "C:\Myfiles\MyProjects\Log4NetTest\LogTest.log" because it is 
> being used by another process.
> 
> When I debug through the code, I find that the writer for the 
> failing class instance is "not defined".
> 
> Here is my config file...
> 
> <?xml version="1.0" encoding="utf-8" ?>
> <configuration>
>       <!-- Register the section handler for the log4net section -->
>       <configSections>
>               <section name="log4net" 
> type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" />
>       </configSections>
> 
>       
>       <log4net debug="true">
>       
>               <appender name="RollingLogger" 
> type="log4net.Appender.RollingFileAppender,log4net">
>                       <param name="File" 
> value="C:\\Myfiles\\MyProjects\\Log4NetTest\\LogTest.log" />
>                       <param name="AppendToFile" value="true" />
>                       
>                       <param name="MaxSizeRollBackups" value="10" />
>                       <param name="MaximumFileSize" value="100KB" />
>                       <param name="RollingStyle" value="Composite" />
>                       <param name="DatePattern" value="yyyyMMdd" />
>                       <param name="StaticLogFileName" value="true" />
> 
>                       <lockingModel 
> type="log4net.Appender.FileAppender+MinimalLock" />
> 
>                       <layout 
> type="log4net.Layout.PatternLayout,log4net">
>                               <param name="ConversionPattern" 
> value="%d [%t] %-5p %c [%x] - %m%n" />
>                       </layout>
>               </appender>
>                               
>               <appender name="DefaultLogger" 
> type="log4net.Appender.ConsoleAppender" >
>                       <layout type="log4net.Layout.PatternLayout">
>                               <param name="ConversionPattern" 
> value="%d [%t] %-5p %c [%x] - %m%n" />
>                       </layout>
>               </appender>
> 
>               <root>
>                   <level value="DEBUG" />
>                   <appender-ref ref="RollingLogger" />
>               </root>
> 
>       
>               
>       </log4net>
> 
>       
> </configuration>
> 
> I tried adding, then removing the <lockingModelsubkey for the 
> appender, with no change.
> As I said, the logging works fine with the ConsoleAppender, 
> but not the file.
> Is this a known problem, or I am I doing something wrong?
> 
> 
> Thanks,
> 
> Mark Stewart
> [EMAIL PROTECTED]
>  
> 
> 
> 
> 

Reply via email to