Announcement Announcement Module
Collapse
No announcement yet.
Problem with CustomizableTraceInterceptor Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problem with CustomizableTraceInterceptor

    CustomizableTraceInterceptor has a feature by which I could ask AOP to put the log message under the object being intercepted. So instead of logs appearing as

    Code:
    org.springframework.aop.interceptor.CustomizableTraceInterceptor:invokeUnderTrace
    I would like the logs to appear as
    Code:
    com.mycompany.web.aop.CustomInterceptor:methodName
    This feature is not working. It's not working because inherently it seems log4j and commons log don't support creating logger for a different class. For example let's look at this class.
    Code:
    public class A {
    	public void testing() {
    		Logger log = Logger.getLogger(B.class);
    		log.debug("### testing");
    	}
    }
    The generated log message is

    Code:
    com.mycompany.A:test:4) - ### testing
    Here I am using log4j and I have created logger for class 'B'. Even though the logger is created for classs 'B' the generated log has 'com.mycompany.A' instead of 'com.mycompany.B'.

    Am I missing something here?

  • #2
    The problem was the configuration with my log4j.properties file.

    This is what I had
    Code:
    log4j.appender.stdout.layout.ConversionPattern=%p [%t] %C.%M(%L) | %m%n
    Notice the capital "C". As per the log4j doc

    %C: Outputs the fully-qualified class name of the caller issuing the logging request.


    %c: Outputs the category of the logging event.
    Switching from uppercase 'C' to lowercase 'c' solved the problem.

    Comment

    Working...
    X