Unable to invoke factory method in class class org apache logging log4j core appender RollingFileAppender

Unable to invoke factory method in class class org apache logging log4j core appender RollingFileAppender

This is very annoying excetion which does give more details to debug it and if your application is big then its little time consuming. You get exception similar to below:

Solution: There could be multiple reason of this error and you have to try one of these to resolve the issue:

  • If you have added new version of code is breaking after that then just checkout the recently added jars and file if any of these contains extra log4j.xml files that is causing issue. In your project you can not keep two log4j.xml file otherwise both will clash with the application. If you are wondering how the two file can be added then one will be from your project other could in jars
  • If above does not work then checkout your log4j.xml file if appenders are added properly or not
  • Check out your log4j.xml log file path if its reading any path information based on environment dynamic varibles if those are added during application startup or not. For example below log file is referring dynamic variables for class path:

Unable to invoke factory method in class class org apache logging log4j core appender RollingFileAppender

  • I am including valid sample log4j2.xml file for reference:

  • This should resolve the issue. For more information on Log4j please refer Apache documentation here

Leave a Reply

Your email address will not be published. Required fields are marked *