Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix exception: Failed to instantiate SLF4J LoggerFactory?

Tags:

java

slf4j

log4j

I am trying to write a java web crawler for semantic web using jena library. I have build project using Netbeans. I am receiving two errors:

  1. Failed to instantiate SLF4J LoggerFactory Reported exception: java.lang.NoClassDefFoundError: org/apache/log4j/Level

  2. Could not initialize class com.hp.hpl.jena.rdf.model.impl.ModelCom at org.slf4j.LoggerFactory.bind(LoggerFactory.java:128)

I have included slf4j-api and slf4j-log both libraries.

like image 372
Prannoy Mittal Avatar asked Mar 06 '13 11:03

Prannoy Mittal


People also ask

What is SLF4J LoggerFactory?

The org. slf4j. Logger interface is the main user entry point of SLF4J API. It is expected that logging takes place through concrete implementations of this interface.

Can SLF4J work without Log4j?

So essentially, SLF4J does not replace Log4j, Both work together. SLF4j removes the tight coupling between the application and logging frameworks. It makes it easy to replace with any other logging framework in the future with a more capable library.

How does SLF4J work with Log4j?

SLF4J standardized the logging levels, which are different for the particular implementations. It drops the FATAL logging level (introduced in Log4j) based on the premise that in a logging framework we should not decide when to terminate an application. The logging levels used are ERROR, WARN, INFO, DEBUG and TRACE.

What is LoggerFactory in Java?

The LoggerFactory is a utility class producing Loggers for various logging APIs, most notably for log4j, logback and JDK 1.4 logging. Other implementations such as NOPLogger and SimpleLogger are also supported.


1 Answers

You should also include log4j library as slf4j-log4j is just a static binder.

like image 174
Filipe Fedalto Avatar answered Nov 03 '22 00:11

Filipe Fedalto