Spring-如何使SoapEnvelopeLoggingInterceptor适应于将标准日志输出到日志文件的形式更正式地记录数据 [英] Spring - How can I adapt SoapEnvelopeLoggingInterceptor to log the data more formally than standard outout to log file

查看:166
本文介绍了Spring-如何使SoapEnvelopeLoggingInterceptor适应于将标准日志输出到日志文件的形式更正式地记录数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试对我的Spring Web服务请求/响应进行正式审核.

I am trying to perform formal auditing of my Spring web services requests/responses.

在我的Spring配置中已经准备好了

I have this in place in my Spring configuration:

<ws:interceptors>   
   <bean class="org.springframework.ws.soap.server.endpoint.interceptor.SoapEnvelopeLoggingInterceptor"/>
</ws:interceptors>

这很好,并将请求和响应记录到我的JBoss日志文件中.不过,我想要的是能够适应这一点并更干净地记录这些请求/响应,以及如何获取数据,以便可以在数据库中写入审核记录.

This is fine, and logs the requests and responses to my JBoss log file. What I want though, is to be able to adapt this and log these requests/responses a little cleaner and how can I get hold of of the data, so I can write to an audit record in the DB.

如何在上面进行调整,以便我可以映射到我的一个bean或类似的bean并获取请求和响应中的数据?

How can I adapt this above so I can map to one of my beans or similar and get hold of of the data in the requests and responses?

推荐答案

您应该只能够创建SoapEnvelopeLoggingInterceptor的子类并覆盖 logMessage(String)做您想做的.示例:

You should just be able to create a subclass of SoapEnvelopeLoggingInterceptor and override logMessage(String) to do what you want. Example:

<ws:interceptors>   
   <bean class="org.mypackage.SysErrLoggingInterceptor"/>
</ws:interceptors>


package org.mypackage;

public class SysErrLoggingInterceptor extends SoapEnvelopeLoggingInterceptor {
    @Override
        protected void logMessage(String message) {
        System.err.println(message); 
        /* Example, here you could be logging to DB or whatever you want */
    }

}

这篇关于Spring-如何使SoapEnvelopeLoggingInterceptor适应于将标准日志输出到日志文件的形式更正式地记录数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆