Results 1 to 5 of 5

Thread: Disabling log.info in production system using Spring AOP

  1. #1
    Join Date
    Jan 2006
    Location
    Bhagalpur, India
    Posts
    11

    Default 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
    Thanks and Regards,
    Jayant K Das

  2. #2
    Join Date
    Dec 2008
    Location
    India
    Posts
    295

    Default

    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.
    Enjoy
    Rohan Chauhan
    ------------------------------------------------------------------------------
    SpringSource Certified Spring 3.0 Professional


  3. #3
    Join Date
    Jan 2006
    Location
    Bhagalpur, India
    Posts
    11

    Default

    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

  4. #4
    Join Date
    Jan 2006
    Location
    Bhagalpur, India
    Posts
    11

    Default

    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
    Thanks and Regards,
    Jayant K Das

  5. #5
    Join Date
    Dec 2008
    Location
    India
    Posts
    295

    Default

    Looks good man!!! If possible try to go with Singleton pattern her(if possible), so multiple instances wont create of your empty logging class.
    Enjoy
    Rohan Chauhan
    ------------------------------------------------------------------------------
    SpringSource Certified Spring 3.0 Professional


Posting Permissions

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