Paulius
Paulius

Reputation: 11

slf4j + log4j problem

I'm trying to configure slf4j with log4j in my java application and I get no success. My log4j file looks like this:

log4j.rootLogger=DEBUG,stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d [%t] %-5p %X{file} %c{1} - %m%n

log4j.logger.lt.hltech.tools.webcrawler=DEBUG,webcrawler
log4j.additivity.lt.hltech.ws.webcrawler=false
log4j.logger.webcrawler=DEBUG,webcrawler
log4j.additivity.webcrawler=false
log4j.appender.webcrawler=org.apache.log4j.DailyRollingFileAppender
log4j.appender.webcrawler.File=D:\\Projects\\IntellijIdeaProjects\\hltech_tools\\WebCrawler\\crawling.log
log4j.appender.webcrawler.DatePattern='.'yyyy-MM-dd
log4j.appender.webcrawler.layout=org.apache.log4j.PatternLayout
log4j.appender.webcrawler.layout.ConversionPattern=%d [%t] %-5p %X{file} %c{1} %m%n
log4j.appender.webcrawler.ImmediateFlush=true

MANIFEST.MF in jar file looks like this:

Manifest-Version: 1.0
Ant-Version: Apache Ant 1.8.2
Created-By: 1.5.0_20-b02 (Sun Microsystems Inc.)
Main-Class: lt.hltech.tools.webcrawler.main.TopicalCrawler
Class-Path: ../../lib/antlr-2.7.6.jar ../../lib/asm-attrs.jar ../../li
 b/asm.jar ../../lib/axis-1.4.jar ../../lib/axis-ant-1.4.jar ../../lib
 /axis-spring-provider-0.1.0.jar ../../lib/cglib-2.1.3.jar ../../lib/c
 heckstyle-5.4-all.jar ../../lib/checkstyle-5.4.jar ../../lib/commons-
 collections-2.1.1.jar ../../lib/commons-logging-1.1.1.jar ../../lib/c
 ommons-logging-adapters-1.1.1.jar ../../lib/commons-logging-api-1.1.1
 .jar ../../lib/dom4j-1.6.1.jar ../../lib/ehcache-1.2.3.jar ../../lib/
 hibernate-annotations.jar ../../lib/hibernate-commons-annotations.jar
  ../../lib/hibernate-entitymanager.jar ../../lib/hibernate-tools.jar 
 ../../lib/hibernate3.jar ../../lib/javassist.jar ../../lib/jaxen-1.1.
 1.jar ../../lib/jaxrpc-1.1-axis14.jar ../../lib/jdbc2_0-stdext.jar ..
 /../lib/jericho-html-3.1.jar ../../lib/jing.jar ../../lib/jta.jar ../
 ../lib/junit.jar ../../lib/log4j-1.2.9.jar ../../lib/mysql-connector-
 java-5.1.6-bin.jar ../../lib/ontopia-vizlet.jar ../../lib/ontopia.jar
  ../../lib/pmd-4.2.6.jar ../../lib/signed-vizlet.jar ../../lib/slf4j-
 api-1.5.11.jar ../../lib/slf4j-log4j12-1.5.11.jar ../../lib/xercesImp
 l-2.6.2.jar ../../src/main/config/log4j.properties

I have added slf4j-log4j12-1.5.11.jar, log4j-1.2.9.jar, slf4j- api-1.5.11.jar and even log4j.properties in my classpath. But the logging doesnt work.

Any ideas how to solve it? Thanks

Upvotes: 1

Views: 2248

Answers (2)

Kasun Kariyawasam
Kasun Kariyawasam

Reputation: 2447

Try out with slf4j-api-1.7.5 , log4j-1.2.17 and slf4j-log4j12-1.7.5 and make sure U have one binder jar (only slf4j-log4j12-1.7.5.jar) in your class path. Then add log4j.properties file into src/main/resources . Just try out with this log4j.properties example.

Upvotes: 1

MaDa
MaDa

Reputation: 10762

At the end of your classpath there's:

../../src/main/config/log4j.properties

As far as I know, classpath can only contain jars, zips or directories. Adding other files has no effect.

Try packing your properties into a jar file or include the directory that contains it.

Upvotes: 0

Related Questions