File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Execption in AOP Logging Program Issue

 
sumanta panda
Ranch Hand
Posts: 224
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1936
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have to provide log4j configuration. Consult log4j documentation.
 
sumanta panda
Ranch Hand
Posts: 224
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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


In your java code append these two lines :-

 
Vivek K Singh
Ranch Hand
Posts: 85
Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:


 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic