• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Log4j in Spring

 
Ranch Hand
Posts: 136
Eclipse IDE Chrome Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is the best method to use Log4j in Spring?

I created a class called log util and declared the required loggers in this class and called the same from my other classes using DI(defining the Logutil class as a property of my other classes)

eg :

Problem with this approach is that I need to declare traceLog property for all my classes I dont want to do that .The only option I can see is to declare a Super class for All clases and delcare traceLog as a property of this super class. I dont want to go down that approach as I dont wanto to create an unwanted super class

Please let me know the best approach to configure Log4j with Spring
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK, Create an AOP Aspect class that just has a Logger and define a pointcut expression that matches all your methods.

Or create a Logger in all your classes, no need to inject it.

Create a log4j.properties file that is at the root of your classpath and put your Log4J configuration stuff in there. No Spring beans needed for Logging.

Mark
 
reply
    Bookmark Topic Watch Topic
  • New Topic