Issue resolved by adding slf4j-log4j12.jar in classpath as mentioned here(http://camel.465427.n5.nabble.com/Log4j-in-Camel-Standalone-Application-td5750730.html#a5750828)
Regards, imran
سؤال
I tried to configure file log4.properties
in my standalone application, it shows on console but i am unable to see it in file, following is my code.
Main Class:
public static void main(String[] args) throws Exception {
Main main = new Main();
main.enableHangupSupport();
main.addRouteBuilder(new TestLogRoute());
main.run();
} //EO main
TestLogRoute Class:
public void configure() throws Exception {
from("timer://foo?delay=0&period=20000")
.log(LoggingLevel.INFO,"Log Configured MT ${body}");
}
Following is my log4j.properties
file under com.my.test.resources
:
log4j.rootLogger=info, stdout, R
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{dd-MMM-yyyy HH:mm:ss:SSS} %5p [%t] - %m%n
log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.File=d:\\logs\\testlogs.log
log4j.appender.R.MaxFileSize=15000KB
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%d %5p [%t] - %m%n
EDIT: In my main class i added the following line, due to this i can see a new log file created in directory but no log get printed in that file:
PropertyConfigurator.configure("log4j.properties");
المحلول
Issue resolved by adding slf4j-log4j12.jar in classpath as mentioned here(http://camel.465427.n5.nabble.com/Log4j-in-Camel-Standalone-Application-td5750730.html#a5750828)
Regards, imran