This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Building Blockchain Apps and have Michael Yuan on-line!
See this thread for details.
Win a copy of Building Blockchain Apps this week in the Cloud/Virtualization 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
  • Liutauras Vilda
  • Knute Snortum
  • Bear Bibeault
Sheriffs:
  • Devaka Cooray
  • Jeanne Boyarsky
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • salvin francis
Bartenders:
  • Tim Holloway
  • Piet Souris
  • Frits Walraven

Execption in AOP Logging Program Issue

 
Ranch Hand
Posts: 224
  • 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

 
Ranch Hand
Posts: 1936
  • 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
  • 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
 
Greenhorn
Posts: 1
  • 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 :-

 
Ranch Hand
Posts: 85
Spring Java
  • 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:


 
Every snowflake is perfect and unique. And every snowflake contains a very tiny ad.
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!