You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4net-user@logging.apache.org by Shaily Goel <gs...@novell.com> on 2004/10/08 07:26:18 UTC
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