my dog learned polymorphism*
The moose likes Other Open Source Projects and the fly likes usage of log4j logging in API Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "usage of log4j logging in API" Watch "usage of log4j logging in API" New topic
Author

usage of log4j logging in API

Nehal Goyal
Greenhorn

Joined: May 15, 2014
Posts: 1
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

Joined: Jul 20, 2005
Posts: 9913
    
158

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

[My Blog] [JavaRanch Journal]
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 9913
    
158


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 agree. Here's the link: http://aspose.com/file-tools
 
subject: usage of log4j logging in API
 
Similar Threads
Log4J configuration problem
How to encapsulate Logger info
Error using log4j in webapp
remove log4j appender from an API
How to configure Log4j to work with Tomcat? and some more questions .