Log4j vs Logback: concurrent writing to same log?

前端 未结 4 848
一个人的身影
一个人的身影 2021-01-04 01:50

I have several web applications running on the same tomcat.

I have two questions:

1- By searching, I understood that when multiple applications are present,

4条回答
  •  半阙折子戏
    2021-01-04 02:08

    In both log4j and logback if multiple FileAppender instances write to the same log file, there is a high risk for the said log file becoming corrupt. Whether the FileAppender instances run on the same JVM or different JVMs is irrelevant, i.e. the risk of corruption is the same.

    As mentioned in the docs, in prudent mode logback's FileAppender will avoid corruption, even in the presence of other FileAppender instances running in the same or different JVMs, potentially running on different hosts. By default, prudent mode is disabled.

    The console cannot be corrupted so the question is moot.

提交回复
热议问题