Reputation: 11
I'm unable to get Camel DSL to print DEBUG logs to the console under Spring Boot by setting the logging.level to the package name in application.properties:
logging.level.org.test.logdemo=debug
<- doesn't print debug logs
If I set the LoggingLevel to INFO or WARN then the log prints:
.when(simple("${exchangeProperty.xmltestresult} == ''"))
.log(LoggingLevel.INFO, "2nd choice ID was empty")
.log(LoggingLevel.WARN, "2nd choice ID was empty")
.log(LoggingLevel.DEBUG,"2nd choice ID was empty")
^ Both INFO and WARN print, DEBUG doesn't print.
If I specify a name for the route, and reference it in the application.properties file, then the DEBUG logs are printed:
logging.level.FileRoute=debug
from("file:///home/user/xmlfilein").routeId("FileRoute")
...
.when(simple("${exchangeProperty.xmltestresult} == ''"))
.log(LoggingLevel.INFO,"2nd choice ID was empty")
.log(LoggingLevel.WARN,"2nd choice ID was empty")
.log(LoggingLevel.DEBUG,"2nd choice was empty")
^ All of these logs are printed.
I've just started working with Camel Spring Boot, and I generated the project using Spring Initializr, which provided the following pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.5.3</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>org.test</groupId>
<artifactId>logdemo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>logdemo</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>11</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-spring-boot-starter</artifactId>
<version>3.11.1</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Setting logging.level.root=debug
works as well, and floods the console with debug messages, which I'm trying to avoid :)
Has anyone else experienced this and come up with a solution? Is there something further up/down the chain that's overwriting the package=debug setting?
Is this a known bug with this version of Camel/Spring Boot? Everything I've read to date states that this should work.
Upvotes: 1
Views: 4585
Reputation: 21
Add a name in the log command :
.log(LoggingLevel.INFO, **"myLog",** "2nd choice ID was empty")
and then in your application.properties :
logging.level.myLog=true
Upvotes: 1
Reputation: 2754
logging.level.org.test.logdemo=debug
This line will only print the logs, which are logged by the classes under org.test.logdemo
package. It will not print apache camel logs which are not explicitly logged.
You can try with
logging.level.org.apache.camel=debug
It will print all logs under org.apache.camel
package.
My suggestion will be first set logging.level.root=debug
, then find out which class or packages are logging your desired information. Then change the
org.apache.camel
to the package or or class name in logging.level.org.apache.camel=debug
For example, if the logs are printed by RouteBuilder
class then the property should be
logging.level.org.apache.camel.builder=debug
Upvotes: 2