在 jboss 中禁用 Axis log4j 日志记录

发布于 2024-07-30 15:28:09 字数 2592 浏览 2 评论 0原文

我有一个小应用程序,它通过网络服务将图片上传到另一个网站。 我当前的问题是,Axis 正在通过 STDOUT 记录整个 xml 消息(包括图片的二进制数据!),我似乎不知道如何禁用它。

我的 jboss (jboss-log4j.xml) 的 log4j 设置包括用于正常 STDOUT 信息日志记录的附加程序,并且我尝试禁用具有不同类别设置的轴:

<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>

将此设置用于 STDOUT:

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

我尝试了这些类别设置,但结果没有任何更改:

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

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

一些示例日志输出如下所示:

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">
 <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  

更新 我检查了 axis-1.4.jar,有一个名为 simplelog.properties 的文件:

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

将其设置为 jar 中的错误,或者设置为 jboss-log4j.xml 中的类别根本没有帮助。

有人知道如何关闭轴日志记录或至少将其设置为错误级别吗?

干杯
坦率

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">
 <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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

场罚期间 2024-08-06 15:30:01

了解正在读取哪个 log4j.properties 文件或 log4j.xml 非常重要。 正如马特指出的,这对于了解为什么你的调整努力不起作用至关重要。

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.

十年九夏 2024-08-06 15:29:47

问题是 Axis 没有使用 Log4j 来记录该消息,因此尝试更改该类上的 log4j 日志记录级别是不相关的。 Axis 使用 System.out.println。

我唯一能想到的(考虑到副作用,这确实不太好)是完全关闭 STDOUT 日志记录。 也许将优先级设置为关闭就可以了。

唯一真正的解决方案是修复 Axis 并修补代码,以便不将 xml 泵送到 System.out,而是使用日志记录机制 - 然后您就可以控制它。

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.

岁月流歌 2024-08-06 15:29:32

首先,您需要检查您的 log4j 配置是否确实是正在读取的配置 - 我记得在过去,至少有一个 axis jar(我认为它可能是 axis-ant.jar >) 因捆绑自己的 log4j.properties 而感到内疚。 log4j 可能正在读取与您不同的配置文件,从而使您调整配置的努力毫无意义!

您可以启用系统属性 -Dlog4j.debug 以使 log4j 打印到标准输出正在读取哪个配置文件。 如有必要,您可以使用 -Dlog4j.configuration= 指向您自己的文件。

另外,我不认为这会导致您的问题,但是您为什么将可加性设置为 false?

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?

洛阳烟雨空心柳 2024-08-06 15:29:18

好吧,在尝试找到更好的解决方案之后,唯一真正的方法是检查旧的遗留代码并将所有 System.out 调用转换为真正的日志记录语句(无论如何要好得多),然后简单地将剩余的 STDOUT 消息过滤到不同的日志中文件。

主要原因之一似乎是 Jboss 本身。 axis2 邮件列表中的此讨论解释了为什么:

啊,但你没有提到你正在使用jboss! 相当有力量
你使用他们的父log4配置。 忽略此中的 axis2 日志记录
案例,请参阅:

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

在那里你必须限制类别。 例如,您有:

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

您可以保持原样,然后从 server.log 中获取日志。

我尝试设置类别,但没有成功。 我认为这是因为 axis 和 axis2 之间的差异。 因此,剩下的唯一解决方案就是采用良好的编码方式,并且不要在自己的代码中使用 STDOUT ;-)

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 ;-)

赠意 2024-08-06 15:29:06

这可能有点晚了,但问题似乎并不在于日志记录本身是在 Axis 中完成的(通过 System.out 和 Commons Logging),而是 LogHandler 存在于处理程序链中。 这就是记录经过时间的方式。

您可以从 Axis 配置文件禁用此处理程序 - server-config.wsdd 和/或 client-config.wsdd,具体取决于您使用 Axis 作为服务器还是客户端。

您在控制台中看到消息的原因可能是由于 LogHandler.writeToConsole 属性设置为 true。 如果将 LogHandler.writeToConsole 设置为 false,则它应写入由 LogHandler.fileName 属性定义的文件。 默认情况下,文件名为 axis.log。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文