Shaily,
You can change the rolling file appender to not keep the file open, this
will slow things down a little but will allow you to have two
applications logging into the same file.
You can set the lockingModel property like this ...
<appender name="RollingFileAppender"
type="log4net.Appender.RollingFileAppender" >
<file value="c:\myfile.txt" />
<appendToFile value="true" />
<rollingStyle value="Size" />
<maxSizeRollBackups value="2" />
<maximumFileSize value="50KB" />
<staticLogFileName value="true" />
<lockingModel
type="log4net.Appender.FileAppender+MinimalLock" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date{ISO8601}
[%appdomain-%thread] %-5level %logger - %message%newline" />
</layout>
</appender>
sdk doc is here....
http://logging.apache.org/log4net/release/sdk/log4net.Appender.FileAppender.LockingModel.html
aaron
Shaily Goel wrote:
I am using Log4net RollingFileAppender to log messages in a local file
and roll the file based on Size and time.
Scenario:
There can be multiple instance of my application running on windows.
All instances log the message using log4net rollingFileAppender into
same file (may be at same time). But when they try doing this, I got the
following error:
log4net:ERROR [LoggerRollingFileAppender] Unable to acquire lock on
file E:\Novell\ZENworks\log\LocalStore\zmd-messages.log. The process
cannot access the file
'E:\Novell\ZENworks\log\LocalStore\zmd-messages.log' because it is being
used by another process.
Please let me know how to solve this issue.
Thanks
Shaily