2013-07-18 19 views
0

我想替换日志中的一些子字符串。使用拥有专有日志功能的JBOSS 6。在jboss中设置替换过滤器6日志记录

例如这样的:

<password>myoutstandingpassword</password> 

<password>xxxxxxxxxxxxxxxxxxxxx</password> 

据我能够通过使用的jboss-logging.xml过滤器来过滤日志中这样的行。

<filter> 
<not><match pattern="password"/></not> 
</filter> 

该过滤器放置在日志处理程序。这完全删除了该行。

但如何删除只有一个子串我不知道。找不到文档。搜索源代码相当耗费。

注意:应该可以在JBOSS AS 6中使用Log4j - http://www.mastertheboss.com/jboss-log/using-log4j-with-jboss-6。在Log4j中,替换可能会完成。我喜欢在没有这个的情况下实施更换。

回答

0

问题是我想过滤掉org.apache.cxf.interceptor.LoggingInInterceptor记录的一些数据。在JBOSS AS 6中实现日志过滤是有问题的,所以最终的解决方案是使用我自己定制的LoggingInInterceptor并对其进行修改。

有人做过这样:

我创建扩展org.apache.cxf.interceptor.LoggingInInterceptor类。

public class CXFLoggingInInterceptor extends LoggingInInterceptor { 

    private String myCustomLogStringOperation(String logString) { 

    ... 

    } 

    @Override 
    protected String transform(String originalLogString) { 
     return myCustomLogStringOperation(originalLogString); 
    } 

} 

通知的overrided方法变换。在那里你会做的文字操作,然后记录!

然后我添加了一个注释到记录完成的Web服务。注释是@OutInterceptors,它将替换默认的拦截器。

@WebService(
    name = .... 
    endpointInterface = .... 
) 
@InInterceptors(interceptors = package.CXFLoggingInInterceptor) 
@Stateless(name = ...) 
@Remote(....) 
@RemoteBinding(jndiBinding = ....) 
public class MyClass implements MyClassInterface 

.... 

CXFLoggingInInterceptor是我们在开始时定义的类。