views:

94

answers:

1

I'm having trouble finding/getting any logging output from a web service.

I have a web service running through axis2 in a Tomcat6 container, the .aar file contains this structure:

root/
    log4j.properties
    lib/
        slf4j-api.jar
        slf4j-log4j12.jar
        log4j-1.2.jar
    com/
        all of my classes
    META-INF/
        services.xml

The service is simple for now, just:

public class MyService {

    private static Logger log = LoggerFactory.getLogger(MyService.class);

    public String echo(String toLog) {
     log.error("Entered echo with [{}]", toLog);

     return "Echo: " + toLog;
    }
}

When run with a main command from a jar file at the command line, the logging works fine, but when accessed as a web service, no logging file is created, but no errors are encountered, either. The client does receive the "Echo: " + toLog string as it expects.

Here's the relevant bits from log4j.properties

### direct messages to file myservice.log ###
log4j.appender.file=org.apache.log4j.FileAppender
log4j.appender.file.File=/var/lib/tomcat6/logs/myservice.log
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n

### set log levels - for more verbose logging change 'info' to 'debug' ###

log4j.rootLogger=warn, file

Do I have the log4j.properties file in the wrong location? Or is something else happening here?

+1  A: 

Axis2 is deployed as a web application in Tomcat, and has its own logging configuration (commons logging). Since it's the one that's invoking your service method, more than likely your logging statements are in Axis2's log files somewhere.

You probably want to know how to have your service log to its own file. I think you'll have to change Axis2's logging configuration and add an appender specifically for your service.

Michael Sharek