阿帕奇骆驼示踪剂|日志级别会影响记录的信息量吗 [英] Apache Camel Tracer | Would log level make a difference in the amout of information logged

查看:30
本文介绍了阿帕奇骆驼示踪剂|日志级别会影响记录的信息量吗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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.

我担心的是,无论日志级别设置如何,Tracer 似乎都会输出相同数量的信息.是这种情况还是我遗漏了什么.

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

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

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 <<<模式:InOnly,标题:{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 --> 变换[简单:${body} at: Tue Apr 22 14:57:17 GMT+05:30 2014] <<<模式:InOnly,标题:{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) 变换[简单:${body} at: Tue Apr 22 14:57:17 GMT+05:30 2014] --> log[OUTPUT: ${body}] <<<模式:InOnly,标题:{CamelFileParent=c:\test,CamelFileLastModified=1398059129189,CamelFileLength=33,breadcrumbId=ID-KLT-IN-PMANCH2-49361-1398158837412-0-1,CamelCopyFileName=1398059129189c:\test\myTest - Copy.txt, CamelFilePath=c:\test\myTest - Copy.txt, CamelFileRelativePath=myTest - Copy.txt, CamelFileNameOnly=myTest - Copy.txt, CamelFileAbsolute=true}, BodyType:String, Body:这是骆驼的再次问候:2014 年 4 月 22 日星期二 14:57:17 GMT+05:30
  • [-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,标题:{CamelFileParent=c:\test,CamelFileLastModified=1398059129189,CamelFileLength=33,breadcrumbId=ID-KLT-IN-PMANCH2-49361-1398158837412-0-1,CamelCopyFileName=1398059129189c:\test\myTest - Copy.txt, CamelFilePath=c:\test\myTest - Copy.txt, CamelFileRelativePath=myTest - Copy.txt, CamelFileNameOnly=myTest - Copy.txt, CamelFileAbsolute=true}, BodyType:String, Body:这是骆驼的再次问候:2014 年 4 月 22 日星期二 14:57:17 GMT+05:30
  • [-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 <<<模式:InOnly,标题:{CamelFileLength=33,CamelFileLastModified=1398059129189,CamelFileRelativePath=myTest.txt,CamelFileName=myTest.txt,CamelFilePath=c:\test\myTest.txt,CamelFileNameOnly=myTest.txt,CamelFile:Absolute\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,标题:{CamelFileLength=33,CamelFileLastModified=1398059129189,CamelFileRelativePath=myTest.txt,CamelFileName=myTest.txt,CamelFilePath=c:\test\myTest.txt,CamelFileNameOnly=myTest.txt,CamelFile:Absolute\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,标题:{breadcrumbId=ID-KLT-IN-PMANCH2-49361-1398158837412-0-3,CamelFileAbsolutePath=c:\test\myTest.txt,CamelFileLength=33,CamelFileName=myTest.txt,CamelFileLast39281891,Modified591CamelFilePath=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: Tue2014 年 4 月 22 日 14:57:17 GMT+05:30
  • [-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,标题:{breadcrumbId=ID-KLT-IN-PMANCH2-49361-1398158837412-0-3,CamelFileAbsolutePath=c:\test\myTest.txt,CamelFileLength=33,CamelFileName=myTest.txt,CamelFileLast39281891,Modified591CamelFilePath=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: Tue2014 年 4 月 22 日 14:57:17 GMT+05:30
  • [-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 <<<模式:InOnly,标题:{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,标题:{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,标题:{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 <<<模式:InOnly,标题:{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 <<<模式:InOnly,标题:{CamelFileLength=33, CamelFileLastModified=1398059129189, CamelFileNameOnly=myTest - Copy (2).txt, CamelFilePath=c:\test\myTest - Copy (2).txt, CamelFileAbsolutePath=c:\test\myTest- 复制 (2).txt,CamelFileRelativePath=myTest - 复制 (2).txt,CamelFileAbsolute=true,breadcrumbId=ID-KLT-IN-PMANCH2-49361-1398158837412-0-7,CamelFileName=myTest - 复制 (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 --> 变换[简单:${body} at: Tue Apr 22 14:57:17 GMT+05:30 2014] <<<模式:InOnly,标题:{CamelFileLength=33, CamelFileLastModified=1398059129189, CamelFileNameOnly=myTest - Copy (2).txt, CamelFilePath=c:\test\myTest - Copy (2).txt, CamelFileAbsolutePath=c:\test\myTest- 复制 (2).txt,CamelFileRelativePath=myTest - 复制 (2).txt,CamelFileAbsolute=true,breadcrumbId=ID-KLT-IN-PMANCH2-49361-1398158837412-0-7,CamelFileName=myTest - 复制 (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) 转换[简单:${body} at: Tue Apr 22 14:57:17 GMT+05:30 2014] --> log[OUTPUT: ${body}] <<<模式:InOnly,标题:{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 <<<模式:InOnly,标题:{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

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

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.

推荐答案

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

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.

关于从 JMX 更改日志级别的问题,重新启动骆驼上下文并检查骆驼跟踪器是否仍然继续记录.

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. 控制日志记录量,因为默认是非常详细的.那可能会在生产日志中生成过多信息.
  2. 使用日志级别来记录信息,以便您的其他用例遇见了.使用不同的日志级别来控制详细程度.

这篇关于阿帕奇骆驼示踪剂|日志级别会影响记录的信息量吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆