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

时间:2014-08-26 14:01:56

标签: java web-services soap cxf

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

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

}

它应该是与以下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>

1 个答案:

答案 0 :(得分:5)

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

public class PrettyLoggingFeature extends LoggingFeature{

    public PrettyLoggingFeature(){
        super.setPrettyLogging(true);
    }
}

之后,我可以在功能上使用这个类。