阻止Apache Camel记录移动文件的完整路径。

huangapple go评论84阅读模式
英文:

Stop Apache Camel from logging full path of file being moved

问题

以下是翻译好的内容:

我正在使用Apache Camel将文件从一个地方移动到另一个地方。在移动过程中,它会记录完整的文件路径。有没有一种方法可以隐藏它?

这里是相关的代码片段:

from(source).routeId(ROUTE_ID)
            .marshal()
            .process(processor)
            .setHeader(Exchange.FILE_NAME, constant("file.txt"))
            .to(destination)
            .end();

这是日志(请在日志末尾检查):

2020-04-04 03:42:49,013 INFO task-1 org.apache.camel.spring.SpringCamelContext doStartOrResumeRouteConsumers - Route: MyRoute started and consuming from: file:///Users/user/Desktop/?include=file.csv

还有一个小问题:
在filePath中使用?fileName="desiredFileName.txt"选项与使用setHeader(Exchange.FILE_NAME, constant("desiredFileName.txt"))之间有区别吗?我怀疑在服务器上添加fileName参数会重命名文件,而不是在本地进行重命名,然后再上传它。

英文:

I'm using Apache Camel for moving a file from one place to another. While moving, it logs the full file path. Is there a way to hide it?

Here's the relevant code snippet:

from(source).routeId(ROUTE_ID)
            .marshal()
            .process(processor)
            .setHeader(Exchange.FILE_NAME, constant("file.txt"))
            .to(destination)
            .end();

And here's the log (please check at the end of the log):

2020-04-04 03:42:49,013 INFO task-1 org.apache.camel.spring.SpringCamelContext doStartOrResumeRouteConsumers - Route: MyRoute started and consuming from: file:///Users/user/Desktop/?include=file.csv

Also I have another small question:
Is there a difference between using ?fileName="desiredFileName.txt" option in the filePath & using setHeader(Exchange.FILE_NAME, constant("desiredFileName.txt")) ? I doubt that adding fileName parameter is renaming file on the server, and not doing it locally, and then uploading it.

答案1

得分: 3

你不能在不更改日志级别或创建自己的Camel核心版本的情况下禁用该日志行。该日志定义在AbstractCamelContext的此行中。但好消息是,它只在路由启动时发生一次。

在选项中使用fileName或Exchange.FILE_NAME标头没有区别。但如果设置了fileName选项,它将覆盖FILE_NAME标头。

英文:

You cannot disable that log line without changing logging level or by creating your own version of camel core. That logging is defined on this line. in AbstractCamelContext. But good thing is that it happens only once when the route ist started.

There is no difference in using fileName in option or the Exchange.FILE_NAME header. But if fileName option is set, it will be used over the FILE_NAME header.

huangapple
  • 本文由 发表于 2020年4月4日 12:02:10
  • 转载请务必保留本文链接:https://go.coder-hub.com/61023609.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定