Results 1 to 2 of 2

Thread: AOP for Logging loosing Contextual Information

Hybrid View

  1. #1
    Join Date
    Jul 2009
    Posts
    1

    Red face AOP for Logging loosing Contextual Information

    Hi,

    I'm very much interested in using Spring AOP for logging the entry and exit of all my classes.

    However, on trying it out, I'm finding that we end up loosing the contextual information of logging when using a LoggingInterceptor.

    What i mean is, using Log4J, we can use pattern like %C.%M to emit the Classname.Methodname in the logs.

    If we use LoggingInterceptor, then this will appear as LoggingInterceptor.invoke() or some other method like that, and the actual method where I want the logging to appear doesn't appear.

    I guess this will be the case all the time in the case of Proxied classes.

    Is there ANY way to introduce code into the actual class itself, so that logging appears as though its coming from those classes?

    Thanks,
    --
    Anish.

  2. #2
    Join Date
    Aug 2004
    Posts
    2,715

    Default

    Quote Originally Posted by Jikes2005 View Post
    Is there ANY way to introduce code into the actual class itself, so that logging appears as though its coming from those classes?
    You might try using AspectJ as it enhances the classes at bytecode level. It is quite easily configured in Spring. Please see the reference manual for details.

    Regards,
    Andreas

Tags for this Thread

Posting Permissions

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