如何在SOAP中启用服务器端的CXF漂亮打印日志记录?

mem*_*und 4 java soap web-services cxf

我有一个soap服务,cxf并希望通过注释启用默认日志记录.我怎么能这样做?

@WebService
@Features(features = "org.apache.cxf.feature.LoggingFeature") //how pretty print?
public class MySoapService {

}
Run Code Online (Sandbox Code Playgroud)

它应该是与以下xml配置等效的注释:

<jaxws:endpoint implementor="de.MySoapService" address="/MySoapService">
    <jaxws:features>
        <bean class="org.apache.cxf.feature.LoggingFeature">
            <property name="prettyLogging" value="true"/>
        </bean>
    </jaxws:features>
</jaxws:endpoint>
Run Code Online (Sandbox Code Playgroud)

小智 5

我能够通过创建一个非常简单的类来解决这个问题,该类扩展LoggingFeature并设置prettyloggingtrue:

public class PrettyLoggingFeature extends LoggingFeature{

    public PrettyLoggingFeature(){
        super.setPrettyLogging(true);
    }
}
Run Code Online (Sandbox Code Playgroud)

之后,我能够在功能上使用这个类.