log4net 读取日志的问题资料
来源:互联网 发布:数组去重的方法 编辑:程序博客网 时间:2024/06/11 02:21
Displaying a Log4Net log file on an ASP.NET website
I wrote a simple web page to display the log file in a textarea from a data synchronization application that logged all it's juicy details to a Rolling log file.
I fired up the page to see my creation and it worked... until the sync service was fired up and started writing to the log file. After that the blasted page just threw a IO exception at me--another process has an exclusive lock on the file and I can't READ it! Turns out it's the default locking mode for FileAppenders but you can configure whatever you are comfortable with.
<appender name=/"RollingFile/" type=/"log4net.Appender.RollingFileAppender/">
<layout type=/"log4net.Layout.PatternLayout/">
<conversionPattern value=/"%d [%t] %-5p %c{1} - %m%n/" />
</layout>
<file value=/"Application.log/" />
<appendToFile value=/"true/" />
<maximumFileSize value=/"500KB/" />
<maxSizeRollBackups value=/"5/" />
<lockingModel type=/"log4net.Appender.FileAppender+MinimalLock/" />
</appender>
The element configures the Appender to use a MinimalLock which only will acquire a lock while it's writing. It appears that it also uses FileShare.Read which will not lock others from just reading it.
It's amazing that this information was so hard to come by, or maybe I was just having a bad google day. At anyrate I thought I'd be a good netcitizen and blog about it so hopeful some poor sap can find this and speed up the troubleshooting--even if that poor sap is me :P
I fired up the page to see my creation and it worked... until the sync service was fired up and started writing to the log file. After that the blasted page just threw a IO exception at me--another process has an exclusive lock on the file and I can't READ it! Turns out it's the default locking mode for FileAppenders but you can configure whatever you are comfortable with.
<appender name=/"RollingFile/" type=/"log4net.Appender.RollingFileAppender/">
<layout type=/"log4net.Layout.PatternLayout/">
<conversionPattern value=/"%d [%t] %-5p %c{1} - %m%n/" />
</layout>
<file value=/"Application.log/" />
<appendToFile value=/"true/" />
<maximumFileSize value=/"500KB/" />
<maxSizeRollBackups value=/"5/" />
<lockingModel type=/"log4net.Appender.FileAppender+MinimalLock/" />
</appender>
The element configures the Appender to use a MinimalLock which only will acquire a lock while it's writing. It appears that it also uses FileShare.Read which will not lock others from just reading it.
It's amazing that this information was so hard to come by, or maybe I was just having a bad google day. At anyrate I thought I'd be a good netcitizen and blog about it so hopeful some poor sap can find this and speed up the troubleshooting--even if that poor sap is me :P
- log4net 读取日志的问题资料
- 关于log4Net 没有日志输出的问题
- Log4Net 生成日志文件名问题
- 解决log4net独占日志文件的问题以及 log4net的各种输出配置(Appender)
- 解决log4net独占日志文件的问题以及 log4net的各种输出配置(Appender)
- log4net的使用 日志输出
- log4net 错误日志的使用
- Log4net 日志文件的操作
- Log4Net的Config配置文件读取
- log4net的问题。
- Log4NET日志
- Log4Net日志
- C#使用正则表达式读取log4net日志文件
- c#应用程序使用log4net组建输出不了日志问题的解决
- log4net的文件日志打印时间测试
- Log4net日志记录组件的使用详解
- 如何跟踪log4net自身的日志
- 动态修改log4net组件的日志文件名
- 在Dll中创建对话框并调用
- Hibernate清理缓存
- Android是什么?
- 在DLL中产生对话框的方法一(Win32 DLL)
- 我的车祸经历
- log4net 读取日志的问题资料
- 在DLL中产生对话框的方法二(MFC Regular DLL)
- Symbian 3rd签名,自签名,开发证书,制造商级别,能力集
- 敏捷测试的最佳实践,第 1 部分: 敏捷的实质
- 螺旋
- Dojo Toolkit 创始人谈Dojo学习
- article
- FMS3中的实用工具(1)——far.exe
- JS+CSS实现Google首页的动画效果