Friday, May 18, 2012
 
The best way to analyze your logs! Minimize
 Log4Net Mail archive   

The Log4Net mailing list is a great source of information about using log4Net, in this forum we collect all the messages in the log4net user list and some selected threads from the developer list.

Subject: Locking of file by RollingFileAppender
Prev Next
You are not authorized to post a reply.

Author Messages
Shaily Goel

03/28/2006 9:15 AM  

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







Aaron Morton

03/28/2006 11:03 AM  

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

You are not authorized to post a reply.
Forums > Log4Net > Log4Net Mail archive > Locking of file by RollingFileAppender



ActiveForums 3.7

 

 

 

 

 

 

 

 

Log4Net Dashboard

Log analysis and monitoring made easy!

Log4Net Dashboard is a log viewer that can read log statements from a variety of logging output targets.

You can download a free developer version.

  

Check it out!

On the demonstration site you can try it  with live data.demo.l4ndash.com - Try Log4Net Dashboard with live data

The mail archive is a copy of all the mail sent to the mail address: log4net-user@logging.apache.org, organized as a forum.

If you would like to participate in the mail list, send a mail to log4net-user-subscribe@logging.apache.org.

More information about the mailing list is available on: http://logging.apache.org/log4net/support.html

 

A complete topic list is available and can be viewed here (warning, it takes some time to load)

 

Copyright 2005-2008 by FaktNet AS Terms Of Use Privacy Statement