Below is my log4j.xml placed in MyProject/src/main/resources
In which i have used FileAppender to redirect the log to log.log
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration>
<appender name="FILE" class="org.apache.log4j.FileAppender">
<param name="file" value="D:/SHARED/log.log"/>
<param name="immediateFlush" value="true"/>
<param name="threshold" value="debug"/>
<param name="append" value="false"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="conversionPattern" value="%m%n"/>
</layout>
</appender>
<logger name="log4j.rootLogger" additivity="false">
<level value="DEBUG"/>
<appender-ref ref="FILE"/>
</logger>
</log4j:configuration>
Below are the dependencies I added in pom.xml
as mentioned in the below link
http://camel.apache.org/how-do-i-use-log4j.html
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
Below is my route which simply sends a file from directory to jms queue
public void configure() throws Exception {
super.configure();
from("file://E://Target//Customers")
.transacted()
.log(LoggingLevel.INFO,"FolderToJMS","Sending File to JMS Queue")
.to("jmstx:queue:transaction-handler");
}
I have deployed my route in service mix. With all these done, im not able to find the log file in D:/SHARED.
Is there something more I need to do...??
Read about pax-logging which is what ServiceMix/Karaf uses. You cannot have your own log configuration, but need to configure using pax-logging.
You can find documentation about this on Karaf website