aspose file tools*
The moose likes Spring and the fly likes Execption in AOP Logging Program Issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Execption in AOP Logging Program Issue " Watch "Execption in AOP Logging Program Issue " New topic
Author

Execption in AOP Logging Program Issue

sumanta panda
Ranch Hand

Joined: Jun 23, 2008
Posts: 224
Dear All,

I am new to spring and using spring 2.0. I am writing an AOP Logging program.

I am not getting compilation error.
While running the Main.java I am getting warning log4j:WARN No appenders could be found for logger (org.springframework.context.support.ClassPathXmlApplicationContext).
log4j:WARN Please initialize the log4j system properly.

My doubt is what i will add the syntax of code in Main.java so that i am getting the output.

[b]”I have added the jar files in the class path .asm-2.2.3.jar, asm-commons-2.2.3.jar, asm-util-2.2.3.jar, aspectjrt.jar, aspectjweaver.jar, spring-aop.jar, spring.jar,log4j.jar, cglib-nodep-2.1_3.jar”


Below given is my code.

Greeter.java


DefaultGreeter.java


MethodLogger.java


Main.Java


MethodLoggerTest-context.xml


Please help/advise me on resolve this issue. .

Thanks for your time.


Best Regards,
Sumanta Panda

Hong Anderson
Ranch Hand

Joined: Jul 05, 2005
Posts: 1936
You have to provide log4j configuration. Consult log4j documentation.


SCJA 1.0, SCJP 1.4, SCWCD 1.4, SCBCD 1.3, SCJP 5.0, SCEA 5, SCBCD 5; OCUP - Fundamental, Intermediate and Advanced; IBM Certified Solution Designer - OOAD, vUML 2; SpringSource Certified Spring Professional
sumanta panda
Ranch Hand

Joined: Jun 23, 2008
Posts: 224
Dear All,
My doubt is what is the piece of code i will add in the Main.Java so that i am able to getting the output.

Please suggest.

Thanks for your time.
Regards,
Sumanta Panda
anshu mishra
Greenhorn

Joined: Sep 16, 2003
Posts: 1

In MethodLoggerTest-context.xml file, add an "id" to the bean


In your java code append these two lines :-

Vivek K Singh
Ranch Hand

Joined: Dec 22, 2009
Posts: 85

there are two issues here:

First: The warning you are getting is generated by log4j, You need to configure log4j to remove this warning. To do that create a log4j.xml configuration file and add a category like this. Also have commons-logging.jar on the class path.



Second: In Main you are just instantiating the spring context, you are not calling anything. So follow the suggsation by Anshu and call the greeter method.

Just a tiny change:



SCJP 6
 
 
subject: Execption in AOP Logging Program Issue