Search code examples
javalog4j

Getting this error: "Could not initialize class org.apache.logging.log4j.LogManager"


enter image description hereI have included all the necessary log4j jar files and I don't understand why I'm still getting this error.

package in.gstzen.einvoice;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;

public class Log4jExample {

    private static Logger logger = LogManager.getLogger(Log4jExample.class);

    public static void main(String[] args) throws Exception {

        System.out.println("Hello World!\n");
        logger.debug("Log4jExample: A Sample Debug Message");
        logger.info("Log4jExample: A Sample Info  Message");
        logger.warn("Log4jExample: A Sample Warn  Message");
        logger.error("Log4jExample: A Sample Error Message");
        logger.fatal("Log4jExample: A Sample Fatal Message");
        System.out.println("Completed...");
    }
}

Solution

  • Please list the jars you added.

    See here: https://www.cwiki.us/questions/13469089/could-not-initialize-class-org.apache.logging.log4j.logmanager