问题描述
prudent Mode 在logback中相同的文件,有可能在不同主机上运行.在其他日志记录框架中,如果从许多日志记录器中输出的输出,则登录到中央TCP(或JMS)Appender似乎是唯一的解决方案.
我使用的是基于log4j的Delphi库,也无法从相同应用程序的不同实例(在终端服务器上)登录相同的文件,因此知道如何实现此功能会很有趣. - P.S.如果没有人更快,我将检查记录源代码,然后回答我的问题:)
推荐答案
问题描述
The prudent mode in logback serializes IO operations between all JVMs writing to the same file, potentially running on different hosts. In other logging frameworks, logging to a central TCP (or JMS) appender seems to be the only solution if output from many loggers should go to the same file.
As I am using a Delphi library which is based on log4j and also can not log to the same file from different instances of the same applications (on a terminal server), it would be interesting to know how this feature is implemented. - p.s. I'll check the logback source code and come back to answer my question if nobody is faster :)
推荐答案
It's implemented with a simple FileLock. You can check in the source of FileAppender.