views:

3120

answers:

5

Hi,

I have small application that is uploading pictures to another website via webservice. My current problem is, that Axis is logging the whole xml message (including the binary data of the picture!) via STDOUT and I can't seem to figure out, how to disable it.

My log4j settings for jboss (jboss-log4j.xml) includes an appender for normal STDOUT Info loggings, and I tried to disable axis with different category settings:

<appender name="STDLOG" class="org.jboss.logging.appender.RollingFileAppender">
  <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
  <param name="File" value="${jboss.server.log.dir}/myapplication.log"/>
  <param name="Append" value="true"/>
    <param name="MaxFileSize" value="5MB"/>
    <param name="MaxBackupIndex" value="10"/>

    <layout class="org.apache.log4j.PatternLayout">
    <param name="ConversionPattern" value="%d %-5p [%c] (%t) %m%n"/>
  </layout>
</appender>

using this setting for STDOUT:

<category name="STDOUT">
  <priority value="DEBUG"/>
  <appender-ref ref="STDLOG"/>
</category>

I tried these category settings without any change in the result:

<category name="log4j.logger.org.apache.axis" additivity="false">
  <priority value="ERROR"/>
</category>

<category name="org.apache.axis">
  <priority value="ERROR"/>
</category>

Some sample log output looks like this:

2009-08-07 10:29:43,911 INFO  [STDOUT] (http-127.0.0.1-8080-1) =======================================================
= Elapsed: 2190 milliseconds
= In message: <?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
 xmlns:xsd="http://www.w3.org/2001/XMLSchema"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;
 <soapenv:Body>
  <addVehicleImage xmlns="urn:VMgrWebService">
   <id xmlns="">APP-T4QKR3U</id>
   <idType xmlns="">chiffre</idType>
   <data xmlns="">9j4AAQSkZJRgABAQAAAQABAAD2wBDAAUDBAQEAwUEBAQFB
     QUGBww0TDMnrXAfKlLjnNJZcciiAOtqk9NG99qhZJKuyYq5k3G
     8P2bVSOpT7rVddRP2Z/yqidRuMMKaO2CXRQNWP2jfOo4S4Bo3W
   removed rest of image data...
     IBwcHBw8LCwkMEQ8SEhEPERETFhwXExQaFRERGCEYGe1UqaZJJy0jSHPGQ
2009-08-07 10:29:43,927 INFO  [STDOUT] (http-127.0.0.1-8080-1) Upload result: true for image mypicture.JPG

Update I checked the axis-1.4.jar and there is a file called simplelog.properties:

# Logging detail level,
# Must be one of ("trace", "debug", "info", "warn", "error", or "fatal").
org.apache.commons.logging.simplelog.defaultlog=info

Setting this to error within the jar, or as a category in jboss-log4j.xml didn't help at all.

Anyone any idea how I can turn off the Axis logging or at least set it to ERROR level?

Cheers
Frank

A: 

First off, you'll want to check that your log4j configuration is actually the one being read - I recall that in the past, at least one axis jar (I think it may have been axis-ant.jar) was guilty of bundling their own log4j.properties. It may be that log4j is reading a different configuration file than yours, making your efforts at tweaking the configuration pointless!

You can enable the system properties -Dlog4j.debug to have log4j print to standard out which configuration file is being read. If necessary, you can use -Dlog4j.configuration=<file> to point to your own file.

Also, I don't think this is causing your issues, but why are you setting additivity to false?

matt b
FrankS
additivity has to be false if you are trying to limit the logging level to only Error, otherwise the line will essentially have no effect if the root level is more inclusive.
Yishai
A: 

The problem is that Axis is not using Log4j to log that message, so attempting to change the log4j logging level on that class isn't relevant. Axis is using a System.out.println.

The only thing I can think of (which is really not nice given the side effects) is to turn the STDOUT logging off altogether. Probably setting the priority to off will do.

The only real solution is to fix Axis and patch the code to not pump the xml to System.out but rather use the logging mechanism instead - then you could control it.

Yishai
Can you point to which class in Axis is doing that? Sounds very strange
matt b
I don't know. If STDOUT is logging the XML, either Axis is doing it, or FrankS is doing it and thinking that Axis is doing it. JBoss redirects any System.out calls to the logs by default (although there are ways to disable that).
Yishai
A: 

Ok, after trying to find a better solution, the only real way was to check the old legacy code and turn all System.out calls into real logging statements (much better anyway), and then simply filter the remaining STDOUT messages into a different log file.

One of the main reasons seems to be Jboss itself. This discussion from the axis2 mailing list explains why: Ahh, but you didn't mention you are using jboss! It pretty much forces you to use their parent log4 config . Ignore the axis2 logging in this case, and see:

~/jboss/server/default/conf/log4j.xml

There you have to limit the categories. For example, you have:

<category name="org.apache">
  <priority value="INFO"/>
</category>

You could leave that as is and just get your logs out of server.log .

I tried setting the category, without success. I assume this is because of differences between axis and axis2. So the only solution left was to go the good coding way and just don't use STDOUT in your own code ;-)

FrankS
+1  A: 

This might be a bit late in the day, but the problem does not seem to be that logging itself is done in Axis (via System.out and Commons Logging), but rather that the LogHandler is present in the handler chain. That is how the elapsed time is getting logged.

You can disable this handler from the Axis configuration file(s) - server-config.wsdd and/or client-config.wsdd, depending on whether you are using Axis as a server or a client.

The reason why you are seeing messages in your console is probably due to the LogHandler.writeToConsole property being set to true. If you set LogHandler.writeToConsole to false, it should write into a file as defined by the LogHandler.fileName property. By default, the file name is axis.log.

Vineet Reynolds
hi, as I mentioned below, I already changed the config so I am not too bothered with it anymore. I still checked for any configuration file, but no success. Do you know if LogHandler.writeToConsol=true is the default setting? This would explain the behaviour.
FrankS
From the Axis source, I deduced that it is not the default.
Vineet Reynolds
A: 

It is very important to know which log4j.properties file or log4j.xml is being read. and as Matt pointed out, this is crucial in knowing why your tweaking efforts are not working.

Vijay Kumar