[slf4j-user] SLF4J with log4j 2

Patrick kc7zzv at gmail.com
Thu Apr 4 18:13:37 CEST 2013


On Apr 4, 2013, at 2:13 AM, Mark James wrote:

> I am new to SLF4J and Java logging in general.
> 
> After some research it seems the best option for a flexible and scalable logging environment is SLF4J and log4j 2.  As I understand it I use SLF4J as the interface (facade) and log4j 2 as the implementation, this also means I can change the implementation (for example to java.util.logging) in the future.
> 
> My problem is setting up a simple hello world project (I'm using NetBeans) as I do not know which combination of jar files are needed.
> 
> Having downloaded SLF4J and log4j 2, there are lots of libraries in each project and I cannot find a combination that works,  would someone be kind enough to tell me exactly which files (full filenames) I need from each project.

I tried to get it working, but I didn' have much luck.  The one thing I did figure out is that it seems that the normal log4j bindings only work with log4j 1.x.  There are some that work better form the apache website, but they still crash and I can't get any output.


For anyone who's interested, this is the Maven config that got me the farthest:
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
      <version>1.7.5</version>
    </dependency>
  <dependency>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-api</artifactId>
    <version>2.0-alpha2</version>
  </dependency>
  <dependency>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-core</artifactId>
    <version>2.0-alpha2</version>
  </dependency>
    <dependency>
      <groupId>org.apache.logging.log4j</groupId>
      <artifactId>slf4j-impl</artifactId>
      <version>2.0-alpha2</version>
    </dependency>


More information about the slf4j-user mailing list