在SOAP服务中使用Log4J过滤掉不需要的日志

我已经创建了一个SOAP客户端,并且我不想看到SOAP调用的日志,因为它们无关紧要。

我只想记录XML SOAP Request调用,例如:

2019-11-28 15:23:26 DEBUG Call:2762 - <?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><RetrieveHeroWeapon xmlns="http://tempuri.org/"><dataEntry><CurrentUser>Sephiroth</CurrentUser><HeroID>123465798</HeroID></dataEntry></RetrieveHeroWeapon></soapenv:Body></soapenv:Envelope>

以及HTTP状态:

2019-11-28 15:29:25 DEBUG DefaultsocketFactory:122 - Created an insecure HTTP connection
2019-11-28 15:29:25 DEBUG ProjectResourceBundle:72 - org.apache.axis.i18n.resource::handleGetObject(xmlSent00)
2019-11-28 15:29:25 DEBUG HTTPSender:484 - XML sent:
2019-11-28 15:29:25 DEBUG HTTPSender:485 - ---------------------------------------------------
2019-11-28 15:29:25 DEBUG SOAPPart:524 - Enter: SOAPPart::saveChanges
2019-11-28 15:29:25 DEBUG HTTPSender:519 - POST /heroService/MobileLegendsService.svc HTTP/1.0
Content-Type: text/xml; charset=utf-8
accept: application/soap+xml,application/dime,multipart/related,text/*
User-Agent: Axis/1.4
Host: mobilelegends.com:9000
Cache-Control: no-cache
Pragma: no-cache
SOAPaction: "http://tempuri.org/MobileLegendsService/RetrieveHeroWeapon"
Content-Length: 462

其他信息,我不想打印:

019-11-28 15:23:25 DEBUG ProjectResourceBundle:72 - org.apache.axis.i18n.resource::handleGetObject(pushHandler00)
2019-11-28 15:23:25 DEBUG DeserializationContext:796 - Pushing handler org.apache.axis.message.SOAPHandler@3f3415b1
2019-11-28 15:23:25 DEBUG ProjectResourceBundle:72 - org.apache.axis.i18n.resource::handleGetObject(newElem00)
2019-11-28 15:23:25 DEBUG MessageElement:239 - New MessageElement (org.apache.axis.message.MessageElement@747c37e1) named {}CoreService
2019-11-28 15:23:25 DEBUG DeserializationContext:765 - Pushing element CoreService
2019-11-28 15:23:25 DEBUG DeserializationContext:1067 - Exit: DeserializationContext::startElement()
2019-11-28 15:23:25 DEBUG DeserializationContext:1078 - Enter: DeserializationContext::endElement(http://tempuri.org/,CoreService)
2019-11-28 15:23:25 DEBUG ProjectResourceBundle:72 - org.apache.axis.i18n.resource::handleGetObject(popHandler00)
2019-11-28 15:23:25 DEBUG DeserializationContext:829 - Popping handler org.apache.axis.message.SOAPHandler@3f3415b1
2019-11-28 15:23:25 DEBUG DeserializationContext:1106 - Popped element stack to org.apache.axis.message.MessageElement:MobileLegendsService
2019-11-28 15:23:25 DEBUG DeserializationContext:1107 - Exit: DeserializationContext::endElement()
2019-11-28 15:23:25 DEBUG DeserializationContext:1003 - Enter: DeserializationContext::startElement(http://tempuri.org/,EnableDelete)

log4j.properties

log4j.rootLogger=DEBUG,stdout,file

log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.MaxFileSize=12MB
log4j.appender.file.MaxBackupIndex=10
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
lxleesjs 回答:在SOAP服务中使用Log4J过滤掉不需要的日志

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/2987063.html

大家都在问