• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

usage of log4j logging in API

 
Nehal Goyal
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
 
Jaikiran Pai
Marshal
Pie
Posts: 10447
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 http://www.coderanch.com/forums/pm/inbox
 
Jaikiran Pai
Marshal
Pie
Posts: 10447
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic