Reputation: 5132
I am trying to get logging working in my Apache Camel project. I have tried the following:
VM args In eclipse I have added tried the following VM args: -Dlog4j.configuration=log4j-/resources/log4j.properties -Dlog4j.debug=true
Properties file on class path I have doubled checked that log4j.properties is on the class path
My java looks like this:
Logger LOG = LoggerFactory.getLogger(CamelMain.class);
LOG.info("starting");
My pom contains the following:
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-core</artifactId>
<version>2.14.1</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-beanio</artifactId>
<version>2.14.1</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.6.1</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.2</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.2</version>
</dependency>
Any ideas why the logging is not working?
Update / Solution
I needed to add the following:
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.6.1</version>
</dependency>
Upvotes: 1
Views: 8617
Reputation: 22963
Add following dependencies if you want to use slf4j
over log4j
and remove the dependencies for org.apache.logging.log4j
and commons-logging
.
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.6.1</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.6.1</version>
</dependency>
Upvotes: 5