How is logback's “prudent mode” implemented?

2019-07-14 14:08发布

问题:

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 :)

回答1:

It's implemented with a simple FileLock. You can check in the source of FileAppender.