Announcement Announcement Module
No announcement yet.
Advanced logging in spring intergration Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Advanced logging in spring intergration

    Hi, all!

    I have an application that process requests from some client devices. All incoming messages contain device identification information and my purpose is to manage standard spring integration logging separately for different messages (for messages from message flow, that was initiated by the certain device). For example, I know, that there is some troubles with the device with ID=5 and I want to log the corresponding messages to another log-file with DEBUG level. I can enrich the incoming message with a header contains this identification information, so all messages from the interesting flow will be marked. But can I specify some logger choice strategy to solve my problem?

  • #2
    Are you talking about relatively fine-grained logging that occurs throughout the system or something more isolated? I would imagine that you are talking about the former, but in case you are talking about the latter, I would recommend using a header-value-router (or SpEL-based router) followed by multiple logging destinations. Those destinations could be simple POJO methods that are referenced by an 'outbound-channel-adapter' or 'service-activator' element. Also, if it fits the problem well, you could combine this strategy with different instances of 'wire-tap' that publish to the router's input-channel or some global 'channel-interceptor' that does something similar.

    Hope that helps, but if not, please provide a bit more detail about the use-case.


    • #3
      Just to add another point you are free to choose whatever enterprise logging system that you want to use. For example your Log4J logger could be just another service-activator and we simply give you options (as Mark suggested with wire-taps, routers and other components) to attach such service-activator to a messages flow (sync or async).


      • #4
        Hello, thanks for your answers. I think using of the global interceptors is my solution. However I'll try to explain my case little bit more. I'm currently using log4j and I like the way Spring integration writes logs. When something goes wrong, I can set log level to DEBUG and I'll see the message that came into my system, transformers that transform messages, routers that route messages and so on. When something goes wrong on production system I'll change the log level without restarting the system and it will help in most cases. Sometimes problems are concerned with a certain client's device so my boss told me: "I want to specify the DEBUG log level for certain device, it will help to solve the problem and will not produce useless overheads". So I want SI to choose the logger according to the message associated with the log record, if any. Are there standard ways to do this?