Question

am exploring the usage of Tracer for logging purpose. It can be managed via JMX Console, so logging can be enabled even when developers haven't used logs in their routes.

My concern is that Tracer seems to output the same amount of information irrespective of the log level set. Is this case or I am missing something.

I am enabling tracing on the route in the Route Builder:

getContext().setTracing(true);
Date d = new Date();

from("file://c:/test?include=myTest.*.txt&noop=true").routeId("myFileTransfer")
.to("log:{body}") // LOG COMPONENT
.transform().simple("${body} at: " + d.toString())
.log("OUTPUT: ${body}") //LOG EIP
.to("file://c:/test_aa")
;

By default, the Tracer outputs the log at INFO level. I changed the level to ERROR using the JMX Console. However, the log seems to same. The log output is reproduced below:

  • [-1) thread #2 - file://c:/test] Tracer INFO ID-KLT-IN-PMANCH2-49361-1398158837412-0-2 >>> (myFileTransfer) from(file://c:/test?include=myTest.*.txt&noop=true) --> log://%7Bbody%7D <<< Pattern:InOnly, Headers:{CamelFileAbsolutePath=c:\test\myTest - Copy.txt, CamelFileAbsolute=true, breadcrumbId=ID-KLT-IN-PMANCH2-49361-1398158837412-0-1, CamelFileParent=c:\test, CamelFileRelativePath=myTest - Copy.txt, CamelFileName=myTest - Copy.txt, CamelFileLength=33, CamelFileNameOnly=myTest - Copy.txt, CamelFileLastModified=1398059129189, CamelFilePath=c:\test\myTest - Copy.txt}, BodyType:org.apache.camel.component.file.GenericFile, Body:[Body is file based: GenericFile[c:\test\myTest - Copy.txt]]
  • [-1) thread #2 - file://c:/test] Tracer INFO ID-KLT-IN-PMANCH2-49361-1398158837412-0-2 >>> (myFileTransfer) log://%7Bbody%7D --> transform[Simple: ${body} at: Tue Apr 22 14:57:17 GMT+05:30 2014] <<< Pattern:InOnly, Headers:{CamelFileAbsolutePath=c:\test\myTest - Copy.txt, CamelFileAbsolute=true, breadcrumbId=ID-KLT-IN-PMANCH2-49361-1398158837412-0-1, CamelFileParent=c:\test, CamelFileRelativePath=myTest - Copy.txt, CamelFileName=myTest - Copy.txt, CamelFileLength=33, CamelFileNameOnly=myTest - Copy.txt, CamelFileLastModified=1398059129189, CamelFilePath=c:\test\myTest - Copy.txt}, BodyType:org.apache.camel.component.file.GenericFile, Body:[Body is file based: GenericFile[c:\test\myTest - Copy.txt]]
  • [-1) thread #2 - file://c:/test] Tracer INFO ID-KLT-IN-PMANCH2-49361-1398158837412-0-2 >>> (myFileTransfer) transform[Simple: ${body} at: Tue Apr 22 14:57:17 GMT+05:30 2014] --> log[OUTPUT: ${body}] <<< Pattern:InOnly, Headers:{CamelFileParent=c:\test, CamelFileLastModified=1398059129189, CamelFileLength=33, breadcrumbId=ID-KLT-IN-PMANCH2-49361-1398158837412-0-1, CamelFileName=myTest - Copy.txt, CamelFileAbsolutePath=c:\test\myTest - Copy.txt, CamelFilePath=c:\test\myTest - Copy.txt, CamelFileRelativePath=myTest - Copy.txt, CamelFileNameOnly=myTest - Copy.txt, CamelFileAbsolute=true}, BodyType:String, Body:This is hello from camel again at: Tue Apr 22 14:57:17 GMT+05:30 2014
  • [-1) thread #2 - file://c:/test] Tracer INFO ID-KLT-IN-PMANCH2-49361-1398158837412-0-2 >>> (myFileTransfer) log[OUTPUT: ${body}] --> file://c:/test_aa <<< Pattern:InOnly, Headers:{CamelFileParent=c:\test, CamelFileLastModified=1398059129189, CamelFileLength=33, breadcrumbId=ID-KLT-IN-PMANCH2-49361-1398158837412-0-1, CamelFileName=myTest - Copy.txt, CamelFileAbsolutePath=c:\test\myTest - Copy.txt, CamelFilePath=c:\test\myTest - Copy.txt, CamelFileRelativePath=myTest - Copy.txt, CamelFileNameOnly=myTest - Copy.txt, CamelFileAbsolute=true}, BodyType:String, Body:This is hello from camel again at: Tue Apr 22 14:57:17 GMT+05:30 2014
  • [-1) thread #2 - file://c:/test] Tracer INFO ID-KLT-IN-PMANCH2-49361-1398158837412-0-4 >>> (myFileTransfer) from(file://c:/test?include=myTest.*.txt&noop=true) --> log://%7Bbody%7D <<< Pattern:InOnly, Headers:{CamelFileLength=33, CamelFileLastModified=1398059129189, CamelFileRelativePath=myTest.txt, CamelFileName=myTest.txt, CamelFilePath=c:\test\myTest.txt, CamelFileNameOnly=myTest.txt, CamelFileAbsolutePath=c:\test\myTest.txt, breadcrumbId=ID-KLT-IN-PMANCH2-49361-1398158837412-0-3, CamelFileParent=c:\test, CamelFileAbsolute=true}, BodyType:org.apache.camel.component.file.GenericFile, Body:[Body is file based: GenericFile[c:\test\myTest.txt]]
  • [-1) thread #2 - file://c:/test] Tracer INFO ID-KLT-IN-PMANCH2-49361-1398158837412-0-4 >>> (myFileTransfer) log://%7Bbody%7D --> transform[Simple: ${body} at: Tue Apr 22 14:57:17 GMT+05:30 2014] <<< Pattern:InOnly, Headers:{CamelFileLength=33, CamelFileLastModified=1398059129189, CamelFileRelativePath=myTest.txt, CamelFileName=myTest.txt, CamelFilePath=c:\test\myTest.txt, CamelFileNameOnly=myTest.txt, CamelFileAbsolutePath=c:\test\myTest.txt, breadcrumbId=ID-KLT-IN-PMANCH2-49361-1398158837412-0-3, CamelFileParent=c:\test, CamelFileAbsolute=true}, BodyType:org.apache.camel.component.file.GenericFile, Body:[Body is file based: GenericFile[c:\test\myTest.txt]]
  • [-1) thread #2 - file://c:/test] Tracer INFO ID-KLT-IN-PMANCH2-49361-1398158837412-0-4 >>> (myFileTransfer) transform[Simple: ${body} at: Tue Apr 22 14:57:17 GMT+05:30 2014] --> log[OUTPUT: ${body}] <<< Pattern:InOnly, Headers:{breadcrumbId=ID-KLT-IN-PMANCH2-49361-1398158837412-0-3, CamelFileAbsolutePath=c:\test\myTest.txt, CamelFileLength=33, CamelFileName=myTest.txt, CamelFileLastModified=1398059129189, CamelFilePath=c:\test\myTest.txt, CamelFileAbsolute=true, CamelFileParent=c:\test, CamelFileNameOnly=myTest.txt, CamelFileRelativePath=myTest.txt}, BodyType:String, Body:This is hello from camel again at: Tue Apr 22 14:57:17 GMT+05:30 2014
  • [-1) thread #2 - file://c:/test] Tracer INFO ID-KLT-IN-PMANCH2-49361-1398158837412-0-4 >>> (myFileTransfer) log[OUTPUT: ${body}] --> file://c:/test_aa <<< Pattern:InOnly, Headers:{breadcrumbId=ID-KLT-IN-PMANCH2-49361-1398158837412-0-3, CamelFileAbsolutePath=c:\test\myTest.txt, CamelFileLength=33, CamelFileName=myTest.txt, CamelFileLastModified=1398059129189, CamelFilePath=c:\test\myTest.txt, CamelFileAbsolute=true, CamelFileParent=c:\test, CamelFileNameOnly=myTest.txt, CamelFileRelativePath=myTest.txt}, BodyType:String, Body:This is hello from camel again at: Tue Apr 22 14:57:17 GMT+05:30 2014
  • [-1) thread #2 - file://c:/test] Tracer INFO ID-KLT-IN-PMANCH2-49361-1398158837412-0-6 >>> (myFileTransfer) from(file://c:/test?include=myTest.*.txt&noop=true) --> log://%7Bbody%7D <<< Pattern:InOnly, Headers:{CamelFileLastModified=1398059129189, CamelFileName=myTest - Copy - Copy.txt, CamelFilePath=c:\test\myTest - Copy - Copy.txt, CamelFileRelativePath=myTest - Copy - Copy.txt, breadcrumbId=ID-KLT-IN-PMANCH2-49361-1398158837412-0-5, CamelFileLength=33, CamelFileAbsolutePath=c:\test\myTest - Copy - Copy.txt, CamelFileParent=c:\test, CamelFileNameOnly=myTest - Copy - Copy.txt, CamelFileAbsolute=true}, BodyType:org.apache.camel.component.file.GenericFile, Body:[Body is file based: GenericFile[c:\test\myTest - Copy - Copy.txt]]
  • [-1) thread #2 - file://c:/test] Tracer INFO ID-KLT-IN-PMANCH2-49361-1398158837412-0-6 >>> (myFileTransfer) log://%7Bbody%7D --> transform[Simple: ${body} at: Tue Apr 22 14:57:17 GMT+05:30 2014] <<< Pattern:InOnly, Headers:{CamelFileLastModified=1398059129189, CamelFileName=myTest - Copy - Copy.txt, CamelFilePath=c:\test\myTest - Copy - Copy.txt, CamelFileRelativePath=myTest - Copy - Copy.txt, breadcrumbId=ID-KLT-IN-PMANCH2-49361-1398158837412-0-5, CamelFileLength=33, CamelFileAbsolutePath=c:\test\myTest - Copy - Copy.txt, CamelFileParent=c:\test, CamelFileNameOnly=myTest - Copy - Copy.txt, CamelFileAbsolute=true}, BodyType:org.apache.camel.component.file.GenericFile, Body:[Body is file based: GenericFile[c:\test\myTest - Copy - Copy.txt]]
  • [-1) thread #2 - file://c:/test] Tracer INFO ID-KLT-IN-PMANCH2-49361-1398158837412-0-6 >>> (myFileTransfer) transform[Simple: ${body} at: Tue Apr 22 14:57:17 GMT+05:30 2014] --> log[OUTPUT: ${body}] <<< Pattern:InOnly, Headers:{CamelFileAbsolutePath=c:\test\myTest - Copy - Copy.txt, CamelFileParent=c:\test, CamelFilePath=c:\test\myTest - Copy - Copy.txt, breadcrumbId=ID-KLT-IN-PMANCH2-49361-1398158837412-0-5, CamelFileRelativePath=myTest - Copy - Copy.txt, CamelFileLength=33, CamelFileAbsolute=true, CamelFileNameOnly=myTest - Copy - Copy.txt, CamelFileName=myTest - Copy - Copy.txt, CamelFileLastModified=1398059129189}, BodyType:String, Body:This is hello from camel again at: Tue Apr 22 14:57:17 GMT+05:30 2014
  • [-1) thread #2 - file://c:/test] Tracer INFO ID-KLT-IN-PMANCH2-49361-1398158837412-0-6 >>> (myFileTransfer) log[OUTPUT: ${body}] --> file://c:/test_aa <<< Pattern:InOnly, Headers:{CamelFileAbsolutePath=c:\test\myTest - Copy - Copy.txt, CamelFileParent=c:\test, CamelFilePath=c:\test\myTest - Copy - Copy.txt, breadcrumbId=ID-KLT-IN-PMANCH2-49361-1398158837412-0-5, CamelFileRelativePath=myTest - Copy - Copy.txt, CamelFileLength=33, CamelFileAbsolute=true, CamelFileNameOnly=myTest - Copy - Copy.txt, CamelFileName=myTest - Copy - Copy.txt, CamelFileLastModified=1398059129189}, BodyType:String, Body:This is hello from camel again at: Tue Apr 22 14:57:17 GMT+05:30 2014
  • [-1) thread #2 - file://c:/test] Tracer ERROR ID-KLT-IN-PMANCH2-49361-1398158837412-0-8 >>> (myFileTransfer) from(file://c:/test?include=myTest.*.txt&noop=true) --> log://%7Bbody%7D <<< Pattern:InOnly, Headers:{CamelFileLength=33, CamelFileLastModified=1398059129189, CamelFileNameOnly=myTest - Copy (2).txt, CamelFilePath=c:\test\myTest - Copy (2).txt, CamelFileAbsolutePath=c:\test\myTest - Copy (2).txt, CamelFileRelativePath=myTest - Copy (2).txt, CamelFileAbsolute=true, breadcrumbId=ID-KLT-IN-PMANCH2-49361-1398158837412-0-7, CamelFileName=myTest - Copy (2).txt, CamelFileParent=c:\test}, BodyType:org.apache.camel.component.file.GenericFile, Body:[Body is file based: GenericFile[c:\test\myTest - Copy (2).txt]]
  • [-1) thread #2 - file://c:/test] Tracer ERROR ID-KLT-IN-PMANCH2-49361-1398158837412-0-8 >>> (myFileTransfer) log://%7Bbody%7D --> transform[Simple: ${body} at: Tue Apr 22 14:57:17 GMT+05:30 2014] <<< Pattern:InOnly, Headers:{CamelFileLength=33, CamelFileLastModified=1398059129189, CamelFileNameOnly=myTest - Copy (2).txt, CamelFilePath=c:\test\myTest - Copy (2).txt, CamelFileAbsolutePath=c:\test\myTest - Copy (2).txt, CamelFileRelativePath=myTest - Copy (2).txt, CamelFileAbsolute=true, breadcrumbId=ID-KLT-IN-PMANCH2-49361-1398158837412-0-7, CamelFileName=myTest - Copy (2).txt, CamelFileParent=c:\test}, BodyType:org.apache.camel.component.file.GenericFile, Body:[Body is file based: GenericFile[c:\test\myTest - Copy (2).txt]]
  • [-1) thread #2 - file://c:/test] Tracer ERROR ID-KLT-IN-PMANCH2-49361-1398158837412-0-8 >>> (myFileTransfer) transform[Simple: ${body} at: Tue Apr 22 14:57:17 GMT+05:30 2014] --> log[OUTPUT: ${body}] <<< Pattern:InOnly, Headers:{CamelFileRelativePath=myTest - Copy (2).txt, CamelFileName=myTest - Copy (2).txt, CamelFileLength=33, breadcrumbId=ID-KLT-IN-PMANCH2-49361-1398158837412-0-7, CamelFileLastModified=1398059129189, CamelFileNameOnly=myTest - Copy (2).txt, CamelFileParent=c:\test, CamelFileAbsolute=true, CamelFileAbsolutePath=c:\test\myTest - Copy (2).txt, CamelFilePath=c:\test\myTest - Copy (2).txt}, BodyType:String, Body:This is hello from camel again at: Tue Apr 22 14:57:17 GMT+05:30 2014
  • [-1) thread #2 - file://c:/test] Tracer ERROR ID-KLT-IN-PMANCH2-49361-1398158837412-0-8 >>> (myFileTransfer) log[OUTPUT: ${body}] --> file://c:/test_aa <<< Pattern:InOnly, Headers:{CamelFileRelativePath=myTest - Copy (2).txt, CamelFileName=myTest - Copy (2).txt, CamelFileLength=33, breadcrumbId=ID-KLT-IN-PMANCH2-49361-1398158837412-0-7, CamelFileLastModified=1398059129189, CamelFileNameOnly=myTest - Copy (2).txt, CamelFileParent=c:\test, CamelFileAbsolute=true, CamelFileAbsolutePath=c:\test\myTest - Copy (2).txt, CamelFilePath=c:\test\myTest - Copy (2).txt}, BodyType:String, Body:This is hello from camel again at: Tue Apr 22 14:57:17 GMT+05:30 2014

Is this the behavior of Tracer, or it can be controlled somehow. In production, we would need to output lesser information to the logs and this is controlled by Log Levels. But this doesn't seems to be case with Tracer.

Was it helpful?

Solution

Logs from tracer should not be confused with camel logging. It starts to output information when log level is >= INFO. So even if you increase the log level from INFO to DEBUG you will see the same amount of logs from tracer.

Regarding your question about changing log level from JMX, restart the camel context and check if still camel tracer continues to log.

As an alternative you override the default camel's tracer implementation and set on camel context. There you

  1. Control the amount of logging since default is very detailed. That might generate too much of information in production logs.
  2. Use log levels to log information so that your other use case is met. Use different log levels to control verbosity.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top