logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Beyers Cronje" <bcro...@gmail.com>
Subject Re: RollingLogFileAppender
Date Tue, 19 Feb 2008 19:07:41 GMT
Thanks all for responding. I ended up using File.Copy on the log file (which
for some reason does not complain about sharing violation) and then opening
a filestream on the copy. I believe in my scenario this will work better
than MinimalLock as performance on MinimalLock apparently is not good and I
rarely need to read the file from another process.

On Feb 19, 2008 5:08 PM, Price, Randall <randallp@vt.edu> wrote:

>  I ran into the same problem and ended up using MinimalLock, mainly
> because it worked.  There may be a better way.
>
>
>
> Here is my code:
>
>
>
> <log4net>
>
>   <appender name="RollingFile" type="log4net.Appender.RollingFileAppender
> ">
>
>
>
>     <file               value="logs\SynchroV4.log"/>
>
>     <appendToFile       value="true" />
>
>     <maximumFileSize    value="2048KB" />
>
>     <maxSizeRollBackups value="-1" />
>
>     <countDirection     value="1" />
>
>     <lockingModel       type="log4net.Appender.FileAppender*+MinimalLock*"
> />
>
>
>
>     <layout type="log4net.Layout.PatternLayout">
>
>       <conversionPattern value="%date [%thread] %-5level %logger -
> %message%newline" />
>
>     </layout>
>
>   </appender>
>
>
>
>   <root>
>
>     <!-- Levels (from lowest to highest):  ALL | DEBUG | INFO | WARN |
> ERROR | FATAL | OFF | -->
>
>     <level value="INFO" />
>
>     <appender-ref ref="RollingFile" />
>
>   </root>
>
> </log4net>
>
>
>
> Hope this helps.
>
>
>
> *Randall Price*
>
>
>
> Secure Enterprise Technology Initiatives
>
> Microsoft Implementation Group
>
> Virginia Tech Information Technology
>
> 1700 Pratt Drive
>
> Blacksburg, VA  24060
>
>
>
> Email:      Randall.Price@vt.edu
>
> Phone:     (540) 231-4396
>
>
>
> *From:* Beyers Cronje [mailto:bcronje@gmail.com]
> *Sent:* Monday, February 18, 2008 5:46 AM
> *To:* log4net-user@logging.apache.org
> *Subject:* RollingLogFileAppender
>
>
>
> Hi all,
>
> Quick question. I am using a RollingLogFileAppender on a webservice.
> Logging works 100%, but whenever I try to open the log file for reading in
> another process I get a sharing violation on the log file. I open the file
> with:
>
> FileStream file = new FileStream(fileName, FileMode.Open, FileAccess.Read,
> FileShare.Read);
>
> Would I have to enable MinimalLock, or is there a way to use ExclusiveLock
> and have another process read from the log file ?
>
> Kind regards
>
> Beyers Cronje
>

Mime
View raw message