1

We have older java code which was using log4j 1.17 and application logs were writing to log file properly. As part of vulnerability fixing we have to migrate to log4j 2.17.2 (Mandatory as part of compliance). We have followed the migration plan as per the Apache blog- https://logging.apache.org/log4j/2.x/manual/migration.html So, now we have added the reference of log4j-1.2-api-2.17.2.jar, log4j-api-2.17.2.jar and log4j-core-2.17.2.jar files instead of log4j-1.17. But, with log4j-2.17, no logs are populating in the log file....though application is running and functionalities also working....but no logs in the log file.

As soon as we refer the log4j-1.17, log files are starts populating. I am not able to figure out what is going wrong here. Below is how the logger was instantiated in old code-

static Logger log = Logger.getLogger(SendApproverDetails.class);

Log4j.Properites files details- enter image description here

Updated the log4j.properites file with @PiotrP.Karwasz suggestion. Still no luck- enter image description here

Cris_new
  • 55
  • 1
  • 10
  • 1
    Difficult to say. I suggest that you build a test app with one class that just logs one message in its main() and migrate that. Maybe it's easier to see where the problems are. – Ralf Renz Apr 04 '22 at 09:49
  • You need to set `log4j1.compatibility=true` if you want to use a Log4j 1.x configuration. – Piotr P. Karwasz Apr 05 '22 at 09:53
  • We have the same problem and I suspect, it is due to our downloading of the `log4j2.xml` via regular (non-encrypted) HTTP -- 2.17.2 only allows such downloads via HTTPS by default. [My own question](/questions/71802718/) asks, how to reenable use of HTTP for this... – Mikhail T. Apr 08 '22 at 20:21
  • @PiotrP.Karwasz- Could you please let me know where i need to set this `log4j1.compatibility=true` property? – Cris_new Apr 11 '22 at 08:13
  • @MikhailT. We are using log4.properties file and we are loading it in our java class. Do i need to modify the log4j properties also to incorporate the log4j 2 changes? My assumption was the bridge jar would take care of this. – Cris_new Apr 11 '22 at 12:25
  • @Cris_new: [this question](https://stackoverflow.com/q/70843538/11748454) explains where you can set Log4j system properties. – Piotr P. Karwasz Apr 11 '22 at 16:25
  • @PiotrP.Karwasz- I just updated the question with the updated log4j.properties file. I have added `log4j1.compatibility=true` in my log4j.properties file. Still no luck! – Cris_new Apr 12 '22 at 12:23
  • Did You find a solution? We are facing a similar problem. – Armando Pinto Jul 12 '22 at 17:20
  • @ArmandoPinto- No, I am continuing using 1.2.17. – Cris_new Aug 05 '22 at 11:35

0 Answers0