TL;DR: I'm trying to use a single logger for both my routes (i.e. the Log EIP) 
and in my components.  In my routes, I would like the displayed log name to be 
the Route ID, and in the components it should be the class name.

Ok, it's about time I solved this one once and for all...

I create my Camel + Spring Boot apps from the Maven/Camel/Spring Boot archetype.

In resources/application.properties, I never bother with the logging level (I 
leave it at INFO) because this never seems to work:

    logging.level.<my-package> = DEBUG

I've tried a number of things, including wilcards, but I can't get a DEBUG log 
level.  So that's the first question: what should the setting be for my 
app/package if I wanted nothing more than that out of the box?

I recently did some digging and learned about adding an SLF4J logger to the 
registry via camel-context.xml:

    <bean id="myLogger" class="org.slf4j.LoggerFactory" 
factory-method="getLogger" xmlns="http://www.springframework.org/schema/beans";>
        <constructor-arg value="<my-package>" />
    </bean>

Now the Log EIP picks up the logging.level.<my-package> settings and I can 
finally do things like:

    .log(LoggingLevel.DEBUG, "DEBUG statement: ${body}");

Great.

However, now "<my-package>" is displayed in the log line and *not* Route ID, 
which I really liked, and was the default when doing a log().

I would really like seeing the Route ID again.  Is there a way to configure the 
logger in the camel-context.xml to display it?  Passing a log name to log() 
doesn't work because it's now picking up the logger from camel-context (and 
it's now set to "<my-package>").

In my components, I can get a LoggerFactory.getLogger(MyClass.class), and that 
logger also now sees the log level in the application.properties.  And it still 
displays the class name and not "<my-package>".  So that's good.

So, in short, I want to have a log level in one place, and get log() in my 
routes to see it and display the Route ID, while having the logger in my 
components also see it but display their class name.  If this can be done 
without configuring a logger in camel-context.xml, that would be great, but I 
don't care either way.  I would like to avoid creating additional log4j/slf4j 
properties files though.  (I did try adding log4j.* and slf4j.* settings to 
application.properties, but that also wasn't working.)

Anyway, thanks guys ... and Happy New Year / Godt Nytår!

Reply via email to