0

We have configured both log4j.xml and log4j2.xml for our application due to certain limitations. The legacy rolling file appender is configured in log4j.xml and the same file appender is used in log4j2.xml. The logs are written to the same file until the threshold for rolling reached. When a new backup file created, the logs defined in log4j2.xml are still writing to the backup file instead of the main file. Is there any way to solve this problem?

Dibyendu
  • 41
  • 6
  • Possible duplicate of [Mixing log4j 1.x and log4j 2](https://stackoverflow.com/questions/26005149/mixing-log4j-1-x-and-log4j-2) – Tim Biegeleisen Sep 25 '19 at 06:13
  • 1
    I suggest piping your `log4j` v1 into `log4j2`, and then just configuring `log4j2` once, in a single place, for your entire application. – Tim Biegeleisen Sep 25 '19 at 06:14
  • How to do piping log4j v1 into log4j2? Is there any reference link where I can check. – Dibyendu Sep 25 '19 at 06:30
  • Look into using SLF4J, [see here](https://logging.apache.org/log4j/2.x/log4j-slf4j-impl/index.html). SLF4J has the ability to re-route your current log4j 1.0 calls into log4j2, via the facade. Your problem has been well researched already, and there are a few solutions out there. – Tim Biegeleisen Sep 25 '19 at 06:33
  • You could use the [log4j 1.2 Bridge](https://logging.apache.org/log4j/2.x/log4j-1.2-api/index.html) to route log4j 1.2 to log4j2 – D.B. Sep 26 '19 at 04:35

0 Answers0