[英]Specify logging level from message header - Spring Integration - Logging Channel Adapter
I have setup a logging channel adapter as shown. 我已经设置了日志通道适配器,如图所示。
<int:logging-channel-adapter id="logger" logger-name="messages"
expression="payload.toLogString()" level="????" />
For the level I want a SpEL expression that accomplishes the logic 对于关卡,我想要一个完成逻辑的SpEL表达式
if(headers.isSet("LoggingLevel"))
level = headers.get("LoggingLevel);
else
level = "INFO";
Preferably using the ternary operator. 优选使用三元算子。
There is not currently a way to dynamically set the log level for the logging channel adapter; 目前没有办法动态设置日志记录通道适配器的日志级别; please feel free to open an 'Improvement' JIRA issue here https://jira.springsource.org/browse/INT
请随时在这里打开'改进'JIRA问题https://jira.springsource.org/browse/INT
In the meantime, you could work around it by defining multiple <logging-channel-adapter>s, each with a different level and use a <header-value-router> to route to the appropriate adapter. 在此期间,您可以通过定义多个<logging-channel-adapter>来解决它,每个<logging-channel-adapter>具有不同的级别并使用<header-value-router>路由到适当的适配器。
You could encapsulate this in an <import>ed config file so you can reuse it in multiple apps. 您可以将其封装在<import> ed配置文件中,以便在多个应用程序中重复使用它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.