使用过滤器记录来自 flex / BlazeDS 客户端的所有请求

发布于 2024-12-19 20:25:06 字数 198 浏览 2 评论 0原文

我有一个 Spring BlazeDS 集成应用程序。我想记录所有请求。

我打算使用过滤器。当我检查请求参数时,在我的过滤器中。它不包含与客户端请求相关的任何内容。如果我更改过滤器的顺序(我有 spring Security),那么它会打印一些与 spring security 相关的内容。

我无法记录用户请求。

任何帮助表示赞赏。

I have a spring BlazeDS integration application. I would like to log all the request.

I planned to use Filter. In my filter when I check the request parameter. It does not contain anything related to the client request. If I change the order of my filter(I have spring Security), then it prints some thing related to spring security.

I am unable to log the user request.

Any help is appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

剧终人散尽 2024-12-26 20:25:06

我通过使用 AOP (AspectJ) 将记录器语句注入通信端点方法来完成相同的功能。 -- 希望这对您来说也是一种替代方法。


/** Logger advice and pointcuts for flex remoting stuff based on aspect J*/
public aspect AspectJInvocationLoggerAspect {

    /** The name of the used logger. */
    public final static String LOGGER_NAME = "myPackage.FLEX_INVOCATION_LOGGER";

    /** Logger used to log messages. */
    private static final Logger LOGGER = Logger.getLogger(LOGGER_NAME);

    AspectJInvocationLoggerAspect() {
    }

    /**
     * Pointcut for all flex remoting methods.
     * 
     * Flex remoting methods are determined by two constraints:
     * <ul>
     *   <li>they are public</li>
     *   <li>the are located in a class of name Remoting* within (implement an interface)
     *   {@link com.example.remote} package</li>
     *   <li>they are located within a class with an {@link RemotingDestination} annotation</li>
     * </ul>
     */
    pointcut remotingServiceFunction()
        : (execution(public * com.example.remote.*.*Remote*.*(..)))  
        && (within(@RemotingDestination *));

    before() : remotingServiceFunction() {
        if (LOGGER.isDebugEnabled()) {
            Signature sig = thisJoinPointStaticPart.getSignature();
            Object[] args = thisJoinPoint.getArgs();

            String location = sig.getDeclaringTypeName() + '.' + sig.getName() + ", args=" + Arrays.toString(args);            
            LOGGER.debug(location + " - begin");
        }
    }

    /** Log flex invocation result at TRACE level. */
    after() returning (Object result): remotingServiceFunction() {

        if (LOGGER.isTraceEnabled()) {
            Signature sig = thisJoinPointStaticPart.getSignature();            

            String location = sig.getDeclaringTypeName() + '.' + sig.getName();
            LOGGER.trace(location + " - end = " + result);            
        }
    }
}

I have done the same functionality by using AOP (AspectJ) to inject a logger statement into communication endpoint methods. -- May this is an alternative approach for you too.


/** Logger advice and pointcuts for flex remoting stuff based on aspect J*/
public aspect AspectJInvocationLoggerAspect {

    /** The name of the used logger. */
    public final static String LOGGER_NAME = "myPackage.FLEX_INVOCATION_LOGGER";

    /** Logger used to log messages. */
    private static final Logger LOGGER = Logger.getLogger(LOGGER_NAME);

    AspectJInvocationLoggerAspect() {
    }

    /**
     * Pointcut for all flex remoting methods.
     * 
     * Flex remoting methods are determined by two constraints:
     * <ul>
     *   <li>they are public</li>
     *   <li>the are located in a class of name Remoting* within (implement an interface)
     *   {@link com.example.remote} package</li>
     *   <li>they are located within a class with an {@link RemotingDestination} annotation</li>
     * </ul>
     */
    pointcut remotingServiceFunction()
        : (execution(public * com.example.remote.*.*Remote*.*(..)))  
        && (within(@RemotingDestination *));

    before() : remotingServiceFunction() {
        if (LOGGER.isDebugEnabled()) {
            Signature sig = thisJoinPointStaticPart.getSignature();
            Object[] args = thisJoinPoint.getArgs();

            String location = sig.getDeclaringTypeName() + '.' + sig.getName() + ", args=" + Arrays.toString(args);            
            LOGGER.debug(location + " - begin");
        }
    }

    /** Log flex invocation result at TRACE level. */
    after() returning (Object result): remotingServiceFunction() {

        if (LOGGER.isTraceEnabled()) {
            Signature sig = thisJoinPointStaticPart.getSignature();            

            String location = sig.getDeclaringTypeName() + '.' + sig.getName();
            LOGGER.trace(location + " - end = " + result);            
        }
    }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文