logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nicko Cadell" <ni...@neoworks.com>
Subject RE: configuration for RollingFileAppender
Date Tue, 12 Oct 2004 18:17:07 GMT
Shaily,

The FileAppender and RollingFileAppender take an exclusive write lock on
the output file. This cannot be shared. Multiple processes need to write
to distinct files.

As far as loading your custom layout, log4net uses the .NET type
resolution, it just calls System.Type.GetType to load the type. Assembly
loading is a function of the runtime. See
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide
/html/cpconHowRuntimeLocatesAssemblies.asp for details on how loading
works and how to configure probing.

Nicko

> -----Original Message-----
> From: Shaily Goel [mailto:gshaily@novell.com] 
> Sent: 08 October 2004 06:26
> To: log4net-user@logging.apache.org
> Subject: configuration for RollingFileAppender
> 
> I have configured Rolling File Appender for writing the 
> events to local log file.
> 
> 	<appender name="RollingFileAppender"
> type="log4net.Appender.RollingFileAppender">
> 	<param name="File" value="/home/sgoyal/localFile.txt" />
> 	<param name="appendToFile" value="true" />
> 	<param name="maxSizeRollBackups" value="2" />
> 	<param name="maximumFileSize" value="1KB" />
> 	<layout type="Novell.Rce.logger.SimpleLayout, 
> LoggerModule.dll"> </layout>
> 
> The two instances of my application is running on single 
> machine . They both configured Rolling File appender with the 
> above configurations . so they both tried to write to same 
> file when events are thrown ("LocalFile.txt").
> Problem: When another instance (or process) want to write to 
> the file which is already used by 1st instance(or process) 
> then it gives an exception 
> 
> log4net:ERROR [RollingFileAppender]
> OpenFile(/home/sgoyal/localFile,True) call f ailed.
> System.IO.IOException: Win32 IO returned 
> ERROR_SHARING_VIOLATION. Path:
> /home/sg oyal/localFile
> in <0x0047d> System.IO.FileStream:.ctor
> (string,System.IO.FileMode,System.IO.Fil
> eAccess,System.IO.FileShare,int,bool)
> in <0x00057> System.IO.FileStream:.ctor
> (string,System.IO.FileMode,System.IO.Fil eAccess) in 
> <0x00073> (wrapper remoting-invoke-with-check) 
> System.IO.FileStream:.ctor (st
> ring,System.IO.FileMode,System.IO.FileAccess)
> in <0x001fc> System.IO.StreamWriter:.ctor
> (string,bool,System.Text.Encoding,int)
> in <0x0001a> System.IO.StreamWriter:.ctor
> (string,bool,System.Text.Encoding)
> in <0x0007d> (wrapper remoting-invoke-with-check) 
> System.IO.StreamWriter:.ctor ( 
> string,bool,System.Text.Encoding) in <0x000ff> 
> log4net.Appender.FileAppender:OpenFile (string,bool) in 
> <0x001fc> log4net.Appender.RollingFileAppender:OpenFile
> (string,bool)
> in <0x00058> log4net.Appender.FileAppender:ActivateOptions ()
>  
> It seems to me the error is because both the processes tries 
> to open the same file and write to it. Is this scenario 
> supported by Log4net(When two instances of application is 
> running , configured for same configurations on single box)? 
> or please let us know if there is any other configuration 
> required on our part to be done to support this scenario. 
> 
> Fyi : I am running the application with super user permission
> 
> 
> 
> Second qusetion : I have configured Rolling File Appender(as seen
> above) to use the my own layout i.e 
> "Novell.Rce.logger.SimpleLayout, LoggerModule.dl" 
> (LoggerModule.dll is the .dll  which contains SimpleLayOut.cs 
> class and "Novell.Rce.logger.SimpleLayout" is the fully 
> qualified path of class SimpleLayOut.cs) 
> 
> Problem : At which location log4net looks for LoggerModule.dll(class
> SimpleLayOut.cs) when it gets initated by DomConfigurator(to 
> configure Rolling File Appender)? currently i fould it looks 
> in /usr/lib ? Can't we specify the path where log4net should 
> look for LoggerModule.dll
> 
> Thanks
> Shaily
> 
> 

Mime
View raw message