Win a copy of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams this week in the Reactive Progamming 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
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

usage of log4j logging in API

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
my scenario is as below
1) Existing application
2) Gives API interface to customize
3) There are sample implementation for these API
4) I want to induce log4j messages in this sample file and use
5) I tried to do the same by
protected final Logger logger = Logger.getLogger(getClass());

and then

logger.info("Calling initialize for AppendLogicToExistingLearningSample");
logger.debug("Calling initialize for AppendLogicToExistingLearningSample");
logger.warn("Calling initialize for AppendLogicToExistingLearningSample");
logger.trace("Calling initialize for AppendLogicToExistingLearningSample");

I am expecting it will pick up the same log4j.properties file as for the application and write to the same log
But this does not happen
in the CLASSPATH I have put the path of the xyz_log4j.properties
what can I do to get the messages

please help



what is PM?

this is my first post so not sure where to see PM

Found PM

Done the changes requested
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Tech Tock wrote:
what is PM?

this is my first post so not sure where to see PM



PM is a "Purple Mooseage" which you can view here https://coderanch.com/forums/pm/inbox
 
Jaikiran Pai
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


in the CLASSPATH I have put the path of the xyz_log4j.properties



The file name has to be log4j.properties or log4j.xml (unless you pass a system property to override that name).

To see if your logging configuration file and configurations are being picked up you can pass a system property while booting the application. More details here.
 
I'm gonna teach you a lesson! Start by looking at this 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!