Log4j dailyrollingfileappender file issues

前端 未结 3 1039
栀梦
栀梦 2020-12-17 02:48

We are encountering a peculiar problem. Scenario: We have 3 servers which with multiple instances of a component all writing transactional log to a single log file.We use lo

3条回答
  •  孤城傲影
    2020-12-17 03:31

    You should not log to the same file from many processes. Log4j is thread-safe all right, but it's not process-safe, if I may say so; it does not work as a shared library among different java processes. Log4j embedded in one java application has no knowledge of any other one.

    With rollover it causes the problem you've just discovered: all processes run their own rollover code, blindly overwriting the previous contents (because none of them expects any).

    A possible solution here: Log4j Logging to a Shared Log File

提交回复
热议问题