0
votes

I'm running some Camel 2.12.2 routes deployed inside ActiveMQ 5.9.0. The ActiveMQ log4j is working as expected, but I'm not able to get a log for my camel application when deployed inside ActiveMQ. My Camel log4j.properties looks like this:

#
# The logging properties used
#
log4j.rootLogger=INFO, console, logger

# uncomment the following line to turn on Camel debugging
#log4j.logger.org.apache.camel=DEBUG

# Console appender
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=%5p | %m%n
log4j.appender.console.threshold=INFO

# File appender
log4j.appender.logger=org.apache.log4j.RollingFileAppender
log4j.appender.logger.file=camel.log
log4j.appender.logger.maxFileSize=1024KB
log4j.appender.logger.maxBackupIndex=5
log4j.appender.logger.append=true
log4j.appender.logger.layout=org.apache.log4j.PatternLayout
log4j.appender.logger.layout.ConversionPattern=%d | %-5p | %m | %c | %t%n

My camel project is using JavaDSL with SpringRouteBuilders, and when running the application with the maven camel plugin and running with

maven camel:run

the camel.log file is produced as expeceted.

However, when packaging the camel routes and moving the jar to ActiveMQ, the log file is no longer created. I've checked the jars for slf4j, log4j and slf4j-log4j, and the versions are the same in ActiveMQ as in my pom.xml.

Any clues as to what I'm missing here?

EDIT: Just to clarify what I'm after here. I've experienced issues on more than one occasaion where ActiveMQ is shutting down because there is something wrong with my camel routes, but I don't see any exceptions in the activemq logs, which makes debugging extremely time consuming. Today I had such an issue, and realised that while there was still no trace of error in the log, I got a stacktrace when just doing maven camel:run on my project. A simple example (really just an example, I know why this is happening, but I want it logged when running in ActiveMQ aswell!)

INFO | Apache Camel 2.12.2 (CamelContext: camel-1) is starting
 INFO | StreamCaching is enabled on CamelContext: camel-1
 INFO | JMX is enabled
 INFO | Using EntityManagerFactory configured: org.springframework.orm.jpa.LocalEntityManagerFactoryBean@2127ee90
 INFO | Using TransactionManager found in registry with id [transactionTemplate] org.springframework.orm.jpa.JpaTransactionManager@449f40f1
 INFO | Apache Camel 2.12.2 (CamelContext: camel-1) is shutting down
 INFO | Apache Camel 2.12.2 (CamelContext: camel-1) uptime 0.477 seconds
 INFO | Apache Camel 2.12.2 (CamelContext: camel-1) is shutdown in 0.010 seconds

When deployed in ActiveMQ, this is the last line I see from Camel

But when running maven camel:run, I'm also seeing this:

 INFO | Apache Camel 2.12.2 stopping
[ERROR] *************************************
[ERROR] Error occurred while running main from: org.apache.camel.spring.Main
[ERROR]
java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.apache.camel.maven.RunMojo$1.run(RunMojo.java:486)
    at java.lang.Thread.run(Thread.java:744)
Caused by: org.apache.camel.RuntimeCamelException: org.apache.camel.FailedToStartRouteException: Failed to start route XPriceChangeToRibRoute because of duplicate id detected: XPriceChangeToRibRoute. Please correct ids to be unique among all your routes.
    at org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1352)
...

So, what I really want is for the last part to be visible also when deployed in ActiveMQ, either in my activemq.log if possible, or as a separate log, e.g. camel.log.

1
You certainly checked if in conf/log4j.properties the log level is correctly set for the camel logs, i.e. log4j.logger.org.apache.camel=INFO?Peter Keller
Yes, I have even tried setting log4j.logger.org.apache.camel=TRACE, but there is still no trace of the exception. Pastebin for entire log with log4j.logger.org.apache.activemq=INFO and log4j.logger.org.apache=INFO here: pastebin.com/SawmGgNH. As you can see there are several log entries from org.apache.camel.*, but the exception is nowhere to be found.Daniel
Did you try to enable Camel tracing: <camel:camelContext xmlns="http://camel.apache.org/schema/spring" trace="true">?Peter Keller
I tried adding trace=true to my context, but the exceptions are still not showing...Daniel
Hm. Did you have a look in wrapper.log? That's where the STDOUT and STDERR should be found.Peter Keller

1 Answers

1
votes

Have a look at wrapper.log. That's where the STDOUT and STDERR should be found. Try to start ActiveMQ with the wrapper, e.g. for MacOS you could use:

apache-activemq-5.9.0/bin/macosx/activemq

Or if that's not an option, redirect STDOUT/STDERR to a log file.