IntelliJ Java IDE
The moose likes Web Services and the fly likes Simple logging from an Axis web service Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Web Services
Reply Bookmark "Simple logging from an Axis web service" Watch "Simple logging from an Axis web service" New topic
Author

Simple logging from an Axis web service

John M. Gabriele
Ranch Hand

Joined: Feb 18, 2001
Posts: 232
How do I just do simple logging from my Axis web service?

For a simple servlet, in the past I've used:

ServletContext context = getServletContext();
context.log( "[Interesting and useful log message goes here]" );

I see that I've got the log4j-1.2.8.jar in my axis/WEB-INF/lib directory.
I suppose I could just do a getLogger() call in my web service object's
methods... Hmm... when using log4j, where is that getLogger() call
supposed to go? Is my web service object persistent between
invocations of the web service methods? Should I be using a private
Logger instance field?

An Axis (v1.x) wiki page has a small amount to say on the matter:
http://wiki.apache.org/ws/FrontPage/Axis/LogWithServletEngine
but it doesn't contain the basic information I'm looking for.

Thanks.
John M. Gabriele
Ranch Hand

Joined: Feb 18, 2001
Posts: 232
Ok, dunno if this is the optimal solution, but here's
what's working for me at the moment:

Created a properties file for log4j:

[some_machine:/home/sanchez/tomcat/webapps/axis/WEB-INF/classes]$ cat log4j.properties
log4j.rootLogger=INFO, some_dest
log4j.appender.some_dest=org.apache.log4j.FileAppender
log4j.appender.some_dest.File=/home/sanchez/tomcat/logs/logariffic_stuff.log
log4j.appender.some_dest.layout=org.apache.log4j.SimpleLayout

and my code (my single .jws file, containing one class), has this
instance field:

private Logger log;

and then, sprinkled throughout the methods is:

log = Logger.getRootLogger();
log.info( "So-and-so *just* happened. You *just* missed it!" );
 
 
subject: Simple logging from an Axis web service
 
Threads others viewed
Getting the Raw Request and Response XML from axis.
Invoking webservice with axis HttpConnection pool
Starting with web service
Experiences with Axis
HowTo Desktop apps & web service
IntelliJ Java IDE