log4net,两个应用程序可以写入同一日志文件吗? [英] log4net, can 2 applications write to the same log file?

查看:374
本文介绍了log4net,两个应用程序可以写入同一日志文件吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用log4net将2个应用程序写入同一日志文件?

Is it possible to have 2 applications write to the same log file using log4net?

推荐答案

他们可以,但是如果一个应用程序正在写入文件,则另一个应用程序也很可能会遇到错误,如果该应用程序也需要写入日志,则由于事实上,第一个应用程序将保持该文件处于打开状态以进行写入.始终最好为应用程序提供专用的日志记录源-如果您需要共享日志,请使用旨在处理并发写入的数据库.

They can but if one application is writing the the file the other application will most likely experience an error if it needs to write to the log as well due to the fact that the first application will be holding the file open for writing. It is always best to have dedicated logging sources for your applications - if you need to share a log, use a database as it is designed to handle concurrent writes.

这是在开发时在您的计算机上确实能很好运行的事情之一,因为您不可能对日志文件创建足够多的并发写入来注意到任何问题.一旦您的应用程序开始承受更多的负载,问题就会开始显现出来,到那时,它可能会以奇怪的方式表现出来.我一定会尝试其他解决方案.

This is one of those things that will work really well on your machine when you are developing since you are not likely to create enough concurrent writes to the log file to notice any problems. Once your application begins to experience more load the problem will begin to show itself and at that point it may manifest itself in strange ways. I would definitely try another solution.

这篇关于log4net,两个应用程序可以写入同一日志文件吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆