Apache Camel Tracer |日志级别会记录所记录的信息量

时间:2014-04-22 09:52:11

标签: logging routing apache-camel

我正在探索使用Tracer进行日志记录。它可以通过JMX控制台进行管理,因此即使开发人员没有在其路由中使用日志,也可以启用日志记录。

我担心的是Tracer似乎输出相同数量的信息而不管日志级别设置如何。是这种情况还是我遗漏了什么。

我在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")
;

默认情况下,Tracer会在INFO级别输出日志。我使用JMX控制台将级别更改为ERROR。但是,日志似乎相同。日志输出如下:

  • [ - 1] thread#2 - file:// c:/ test] Tracer INFO ID-KLT-IN-PMANCH2-49361-1398158837412-0-2>>> (myFileTransfer)来自(file:// c:/ test?include = myTest。* .txt& noop = true) - > log://%7Bbody%7D<<<模式: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,正文:[正文基于文件: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 - >变换[简单:$ {body} at:Tue Apr 22 14:57:17 GMT + 05:30 2014]<<<模式: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,正文:[正文基于文件:GenericFile [c:\ test \ myTest - Copy.txt]]
  • [ - 1] thread#2 - file:// c:/ test] Tracer INFO ID-KLT-IN-PMANCH2-49361-1398158837412-0-2>>> (myFileTransfer)转换[简单:$ {body} at:Tue Apr 22 14:57:17 GMT + 05:30 2014] - > log [OUTPUT:$ {body}]<<<模式: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 :这是骆驼的再次问候: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<<<模式: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 :这是骆驼的再次问候: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)来自(file:// c:/ test?include = myTest。* .txt& noop = true) - > log://%7Bbody%7D<<<模式: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 :[正文基于文件: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 - >变换[简单:$ {body} at:Tue Apr 22 14:57:17 GMT + 05:30 2014]<<<模式: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 :[正文基于文件:GenericFile [c:\ test \ myTest.txt]]
  • [ - 1] thread#2 - file:// c:/ test] Tracer INFO ID-KLT-IN-PMANCH2-49361-1398158837412-0-4>>> (myFileTransfer)转换[简单:$ {body} at:Tue Apr 22 14:57:17 GMT + 05:30 2014] - > log [OUTPUT:$ {body}]<<<模式: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:这是来自Camel的hello:Tue 4月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<<<模式: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:这是来自Camel的hello:Tue 4月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)来自(file:// c:/ test?include = myTest。* .txt& noop = true) - > log://%7Bbody%7D<<<模式: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 - >变换[简单:$ {body} at:Tue Apr 22 14:57:17 GMT + 05:30 2014]<<<模式: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)转换[简单:$ {body} at:Tue Apr 22 14:57:17 GMT + 05:30 2014] - > log [OUTPUT:$ {body}]<<<模式: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:这是来自骆驼的问候: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<<<模式: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:这是来自骆驼的问候: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&gt;&gt;&gt; (myFileTransfer)来自(file:// c:/ test?include = myTest。* .txt&amp; noop = true) - &gt; log://%7Bbody%7D&lt;&lt;&lt;模式: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]] < / LI>
  • [ - 1] thread#2 - file:// c:/ test] Tracer ERROR ID-KLT-IN-PMANCH2-49361-1398158837412-0-8&gt;&gt;&gt; (myFileTransfer)log://%7Bbody%7D - &gt;变换[简单:$ {body} at:Tue Apr 22 14:57:17 GMT + 05:30 2014]&lt;&lt;&lt;模式: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]] < / LI>
  • [ - 1] thread#2 - file:// c:/ test] Tracer ERROR ID-KLT-IN-PMANCH2-49361-1398158837412-0-8&gt;&gt;&gt; (myFileTransfer)转换[简单:$ {body} at:Tue Apr 22 14:57:17 GMT + 05:30 2014] - &gt; log [OUTPUT:$ {body}]&lt;&lt;&lt;模式: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:这是来自骆驼的问候: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&gt;&gt;&gt; (myFileTransfer)log [OUTPUT:$ {body}] - &gt; file:// c:/ test_aa&lt;&lt;&lt;模式: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:这是来自骆驼的问候:Tue Apr 22 14:57:17 GMT + 05:30 2014

这是Tracer的行为,还是可以某种方式控制它。在生产中,我们需要向日志输出较少的信息,这由日志级别控制。但对于Tracer来说,这似乎并非如此。

1 个答案:

答案 0 :(得分:0)

来自跟踪器的日志不应与骆驼日志记录混淆。当日志级别为> = INFO时,它开始输出信息。因此,即使您将日志级别从INFO增加到DEBUG,您也会看到来自跟踪器的相同数量的日志。

关于从JMX更改日志级别的问题,重新启动camel上下文并检查是否仍有camel tracer继续记录。

作为替代方法,您可以覆盖默认的camel跟踪器实现并在camel上下文中设置。你在那里

  1. 控制记录量,因为默认值非常详细。那 可能会在生产日志中生成太多信息。
  2. 使用日志级别记录信息,以便您的其他用例     满足。使用不同的日志级别来控制冗长。