1
votes

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

if(headers.isSet("LoggingLevel"))
  level = headers.get("LoggingLevel);
else
  level = "INFO";

Preferably using the ternary operator.

1

1 Answers

3
votes

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

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.

You could encapsulate this in an <import>ed config file so you can reuse it in multiple apps.