Logging from multiple processes using log4net
When logging with log4net to a file (using the FileAppender), the FileAppender is holding an exclusive write lock on the file. This doesn’t cause any problems, not even when the application is running with multiple threads, because
log4net should be thread-safe.
This does change however when working with multiple processes, that all share a common log4net configuration and
thus all will utilize the same FileAppender.
This prevents other processes from writing to the file and usually the error "The
process cannot access the file 'xxx.log' because it is being used by another process." will show. In this
case there should not be an exclusive write lock by any process. Fortunately log4net has an appropriate configuration-setting, then all processes will write to the same log file.
|
1
|
<lockingModeltype="log4net.Appender.FileAppender+MinimalLock"/>
[...]</appender> |
But acquiring and release locks is quite costly and thus will slow down the overall performance of the application.
An alternative would be to create an individual log per processes. Luckily log4net supports the expansion of variables to generate log-filenames, so we can add the process-id to the filename-pattern.
|
1
2
3
4
|
<appendername="LogFileAppender"type="log4net.Appender.RollingFileAppender,log4net"> <filetype="log4net.Util.PatternString"value="Log[%processid]"/>[...]</appender> |
Logging from multiple processes using log4net的更多相关文章
- RuntimeError: Cannot run in multiple processes: IOLoop instance has already been initialized. You cannot call IOLoop.instance() before calling start_processes()
解决方法: settings中的debug改为false,或者注释掉 参照: https://stackoverflow.com/questions/32521122/cannot-run-in-mu ...
- log4net RemotingAppender 的配置
Before you even start trying any of the alternatives provided, ask yourself whether you really need ...
- log4net的各种Appender配置示例
Apache log4net™ Config Examples Overview This document presents example configurations for the built ...
- Apache log4net™ Config Examples
Overview This document presents example configurations for the built-in appenders. These configurati ...
- lockingModel in log4net 日志文件不能被其他进程写入
http://logging.apache.org/log4net/release/faq.html#single-file How do I get multiple process to log ...
- Log4Net 手册
首先感慨下,现在的程序员做的工作因为高级语言的生产力,系统框架模式的成熟,开源大牛的贡献,已经成越来越偏向 “面向配置编程”了...... 详细使用指南见文章:http://blog.csdn.net ...
- Python 中 logging 日志模块在多进程环境下的使用
因为我的个人网站 restran.net 已经启用,博客园的内容已经不再更新.请访问我的个人网站获取这篇文章的最新内容,Python 中 logging 日志模块在多进程环境下的使用 使用 Pytho ...
- Log4net - 规则简介
参考页面: http://www.yuanjiaocheng.net/CSharp/csharprumenshili.html http://www.yuanjiaocheng.net/entity/ ...
- Log4net - 项目使用的一个简单Demo
参考页面: http://www.yuanjiaocheng.net/entity/entitytypes.html http://www.yuanjiaocheng.net/entity/entit ...
随机推荐
- SpringMVC之controller篇1
概述 继 Spring 2.0 对 Spring MVC 进行重大升级后,Spring 2.5 又为 Spring MVC 引入了注解驱动功能.现在你无须让 Controller 继承任何接口,无需在 ...
- linux 压缩命令
.zip格式压缩 zip 压缩文件名 源文件 压缩文件 zip -r 压缩文件名 源目录 #压缩目录 .zip格式解压缩 unzip 压缩文件 #解压缩 .gz格式压缩 gzip ...
- 网站文章分享到微博,微信、qq空间--举例用织梦
有对应接口的,传递参数过去就行了,注意下面的{..},需要替换为你的内容,看参数名称你应该知道是什么东东 新浪地址接口http://service.weibo.com/share/share.php? ...
- android开发中一个activity如何调用另一个xml中的控件
有时候,我们需要在一个activity中使用另一个activity中的控件,这时候就不能直接findViewById,不然会报错指向空对象,这时就需要像下面这样做. LayoutInflater fa ...
- hdu 5693 && LightOj 1422 区间DP
hdu 5693 题目链接http://acm.hdu.edu.cn/showproblem.php?pid=5693 等差数列当划分细了后只用比较2个或者3个数就可以了,因为大于3的数都可以由2和3 ...
- spring boot 整合 RabbitMq (注解)
1.增加rabbitmq的依赖包 <!-- ampq 依赖包 --> <dependency> <groupId>org.springframework.boot& ...
- Python如何管理内存?
对于Python来说,内存管理涉及所有包含Python对象和堆. Python内存管理器在内部确保对堆的管理和分配. Python内存管理器具有不同的组件,可处理各种动态存储管理方面,如共享,分段,预 ...
- JWT设计实现
一.JWT基于token的认证流程: 二.JWT SDK的选取: https://jwt.io/ 三.编写JWT Helper: 1.获取token 设置密钥,规定算法,设置过期时间,设置发行方,生命 ...
- 移动端Android软键盘遮住输入框解决!
在使用vue的情况下,在输入框中添加 <textarea class="textarea" @click="isAndroid" :maxlength=& ...
- 812. Largest Triangle Area
static int wing=[]() { std::ios::sync_with_stdio(false); cin.tie(NULL); ; }(); class Solution { publ ...