Win a copy of Succeeding with AI this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
  • Junilu Lacar
Sheriffs:
  • Tim Cooke
  • Jeanne Boyarsky
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • fred rosenberger
  • Frits Walraven

Aspectj & Log4j problem

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I'm having an issue with Log4j and Aspectj. I've configured logging in my application using Aspects. I have defined pointcuts for all method in my app and before and after advice to log using commons logging. I use log4j as the logging implementation

In the aspect I create the logger

private Log log = LogFactory.getLog("trace");

and in the before and after advise I have simple log statements

log.debug("Entering Method");

I can see that the aspects are executing before and after each method and the debug statements are being executed.

I then config log4j loggers configuration as follows so that the entering & exiting messages only appear in the trace-file appender.

<logger name="com.myapp" additivity="false">
<level value="debug"/>
<appender-ref ref="trace-file" />
</logger>
<root>
<priority value="info" />
<appender-ref ref="console" />
<appender-ref ref="trace-file" />
</root>

However my debug log statments from the aspectj are not output on the com.myapp logger. If I use log.debug statement anywhere else my app the they are ouput successfully. Also if I change the root logger level to debug the aspectj log statements are output to my appenders.

What I can't understand is why the log statements from the aspects are not output on my custom logger.

Anyone got an example of this that I can see?

Thanks in advance
 
My name is Inigo Montoya, you killed my father, prepare to read a tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic