Results 1 to 4 of 4

Thread: Logger for a logging-channel-adapter?

  1. #1
    Join Date
    Jul 2005
    Location
    Austin, TX
    Posts
    137

    Default 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. #2
    Join Date
    Jul 2005
    Location
    Austin, TX
    Posts
    137

    Default

    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

  3. #3
    Join Date
    Oct 2005
    Location
    Boston, MA
    Posts
    2,840

    Default

    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?

  4. #4
    Join Date
    Jul 2005
    Location
    Austin, TX
    Posts
    137

    Default

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •