Announcement Announcement Module
Collapse
No announcement yet.
Logger for a logging-channel-adapter? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Logger for a logging-channel-adapter?

    If I'm using a <logging-channel-adapter>, how do I specify the logger?

    I've only been able to get the logging channel adapter to show messages logged to it when the logger named "org.springframework.integration.handler" in my log4j.xml/log4j.properties has a level set to the "level" attribute of the <logging-channel-adapter> (or below). Problem is, I see more logging than just my application messages -- I see log messages from the Spring Integration framework classes as well.

    What plans are there to allow the user to provide a logger name so that I can log Spring Integration handler messages to one logger, and actual messages to another logger, like the following?
    Code:
    <logging-channel-adapter id="logger" level="DEBUG" logger="org.example.foo.bar"/>
    This would allow me to set the threshold of the logger "org.example.foo.bar" to a level that differs from that of the logger named "org.springframework.integration.handler".

    -matthew

  • #2
    After looking at the source of LoggingHandler, it might be as simple as adding a property of type String called "userLogger" (or "userLoggerName") and replacing calls in method LoggingHandler#handleMessageInternal(Message<?>) with something like the following:
    Code:
            final Log userLogger = LogFactory.getLog(this.getUserLogger()); // instead of current field called "logger"
            switch (this.level) {
             case FATAL:
                if (userLogger.isFatalEnabled()) {
                    userLogger.fatal(logMessage);
                }
                break;
             // etc...
    WDYT?

    -matthew

    Comment


    • #3
      I like the idea of specifying a logger name. I'm wondering if it could be taken from the "id" value of the adapter itself?... or do you see value in having a separately configurable value there?

      Comment


      • #4
        I would expect the default behavior to be the same as what it currently is, but I certainly like using the id as the user logger name. If you don't care about changing the default, then I'd say use the id value as the user logger name unless the user's logger name is given.

        -matthew

        Comment

        Working...
        X