0
votes

I want to migrate from Log4J 1.x to Log4J 2 but at the same time I want to keep Log4J to support any external features (jars) that use Log4J. There are custom appenders written in Log4J and so the appenders will be re-written according to Log4J2 using plugins. So two configuration files needs to be there to support each version and the logs from both versions need to be written to the same file with the same format as defined in the custom appenders.

I found that simultaneous writing of multiple appenders to the same file is possible within a version but is it possible for the appenders coming from two Log4J versions to write to the same file simultaneously? If yes is it a recommended practice and please suggest an alternative if it is not recommended.

1

1 Answers

1
votes

It would be an unusual setup to use both Log4j2 and Log4j 1.2 (not the adapter but the actual implementation) to do logging for an application at the same time.

Configuring both logging libraries to write to the same file adds even more risk. It might work, it might not. It is certainly not what these libraries were designed for.

I would not recommend such a setup.

The safest thing to do would be to postpone your Log4j2 migration until your log4j 1.2 custom appenders have been ported to Log4j2. Then use the Log4j2 implementation and the log4j-1.2-api-2.x adapter module for the external libraries that use the Log4j 1.2 API.