• 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

usage of log4j logging in API

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic