Announcement Announcement Module
Collapse
No announcement yet.
logging intercept help needed Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • logging intercept help needed

    Hi,

    I am new to spring..implementing logging aspect...i have couple of questions

    1) my java objects do not have interfaces.do i need to create interfaces to all of my java objects to use logging aspect with spring.if yes then is there any easy solution...

    2) generally we have log statements to print a value or who logged or return values from a particular method call inside a method like below..Can these also be proxied through interceptors ?

    public myMethod (list a, string b) {

    log.debug ("user : " + session.getUser ());
    log.debug ("value of b" + b);

    list c = getEmplyoeesFromDB ();

    log.debug ("Employees from db : "+ c);
    }

    in the above method i have 3 log statements...can i take those out and have in my interceptor so that my developer can enable particular logging for a particular method if needed through patterns in xml ..if yes can u provide a sample code or config to do same..if not then can we only trace before, after calling a method and during exceptions..and still we need to write custom logging inside mehods ?

    appreciate ur help..

    thanks in advance

  • #2
    Yes, you can use a tracing intercept for this, and it will be invoked at particular points (before, after, around, for exception, etc). But, I think you will still need to use logging, if logging will be needed at other locations in a method, with easy AOP anyway.

    To me, tracing and logging are different. Logging requires developer insight into what is happening and what is important, thus, the message string is important. Whereas, tracing is mechanical. Also, the performance requirements are different. Logging is in the code longer term, so it should have minimal impact and allow external configuration (log levels for example).

    Comment


    • #3
      help needed

      Thanks for the reply...i think i still did not understand or got reply for question 1)...

      1) my java objects do not have interfaces.do i need to create interfaces to all of my java objects to use logging aspect with spring.if yes then is there any easy solution...

      2) Can u point me or give a sample how to implement logging and tracing interceptors...


      thanks in advance.

      Comment


      • #4
        Some good posts are going on right now on this topic here: http://forum.springframework.org/showthread.php?t=28255

        Comment

        Working...
        X