Announcement Announcement Module
Collapse
No announcement yet.
Disabling log.info in production system using Spring AOP Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Disabling log.info in production system using Spring AOP

    Hi All,

    I am currently in a situation where logs in our production system are printed continuously from quite a few domain classes which are not relevant, thus cluttering and increasing the size of the log file. The system does use Spring 2.0.8 but the domain classes are not tied with it. I was trying to find out a solution using the Spring AOP(and/or AspectJ), where I can control the logging information being printed from the files identified.

    E.g.,

    10 domain classes are printing in a particular method something like -- log.info("ABCD"). I want to either disable this or change this particular log line to something like -- log.debug("ABCD"). I have been doing a google but have not been able to find out a concrete answer on how to disable logging in an existing system.

    Any help is really appreciated.


    Regards,
    Jayant

  • #2
    Jayant as you mentioned some classes are not managed by Spring, then you cant use Spring AOP for that classes. But those which are registered for them you can use Spring.
    Also from your question it looks like you want to change logging lines. Its not possible directly but ya better idea is for those beans you can use Spring AOP and let them redirect to some other location/file.

    Comment


    • #3
      Thanks Rohan for the info. I had a bit of idea that Spring AOP can't be used if classes are not managed by Spring and thus the problem. The problem here is that the code base is bulky enough and changing the lines would call for lots of changes across the code base. I had been knowing about AOP concepts but not in the form exactly I am looking for now.

      Would you be able to share some thoughts on what if I use aspectj directly, would it be possible to change those logging lines. I am not sure which king of advice would be useful here, but I assume this would incur an overhead of introducing ajc compiler.

      Regards,
      Jayant

      Comment


      • #4
        Rohan, on your note I tried doing something different though. As my requirement was to change the implementation at runtime (specifically changing info to debug), I tried doing it differently. Need to review more on it. I implemented the logger class and in the log method did nothing. Now using plain reflection, assigned the value of this new logger class thus achieving what I had been looking for. But it would be great if could put some thoughts on this.

        Regards,
        Jayant

        Comment


        • #5
          Looks good man!!! If possible try to go with Singleton pattern her(if possible), so multiple instances wont create of your empty logging class.

          Comment

          Working...
          X