logfilter.java

来自「银行项目为后台socket通信写的程序」· Java 代码 · 共 81 行

JAVA
81
字号
/****************************************************************************
 * Package		: com.ecSolutions.ecAppServer.server.filter
 * File			: LogFilter.java
 * Create Date  : 2007-7-20
 * Author		: Steven Chen
 * 
 * Copyright(C) 2006 ecSolutions(shanghai) Co.,Limited.All Rights Reserved.
 *			
 ***************************************************************************/
package com.ecSolutions.ecAppServer.server.filter;

import com.ecSolutions.ecAppServer.server.Packet;
import com.ecSolutions.ecAppServer.server.SessionFilterAdapter;
import com.ecSolutions.ecAppServer.server.SessionFilterChain;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 * Log filter.
 * 
 * @author Steven Chen
 * @version $Id: LogFilter.java,v 1.2 2007/07/26 03:24:37 stevenchen Exp $
 */
public class LogFilter extends SessionFilterAdapter {

    private static final Log log = LogFactory.getLog(LogFilter.class);

    public void exceptionCaught(SessionFilterChain filterChain, Throwable cause) {
        log.error(filterChain.getSession() + " caught exception: " + cause,
                cause);
        super.exceptionCaught(filterChain, cause);
    }

    public void packetReceived(SessionFilterChain filterChain, Packet packet)
            throws Exception {
        log.info(filterChain.getSession() + " received packet: " + packet);
        super.packetReceived(filterChain, packet);
    }

    public void objectReceived(SessionFilterChain filterChain, Object obj)
            throws Exception {
        log.info(filterChain.getSession() + " received object: " + obj);
        super.objectReceived(filterChain, obj);
    }

    public void packetSend(SessionFilterChain filterChain, Packet packet)
            throws Exception {
        log.info(filterChain.getSession() + " send packet: " + packet);
        super.packetSend(filterChain, packet);
    }

    public void packetSent(SessionFilterChain filterChain, Packet packet)
            throws Exception {
        log.info(filterChain.getSession() + " sent packet: " + packet);
        super.packetSent(filterChain, packet);
    }

    public void objectSent(SessionFilterChain filterChain, Object obj)
            throws Exception {
        log.info(filterChain.getSession() + " sent object: " + obj);
        super.objectSent(filterChain, obj);
    }

    public void sessionClosed(SessionFilterChain filterChain) throws Exception {
        log.info(filterChain.getSession() + " closed");
        super.sessionClosed(filterChain);
    }

    public void sessionStarted(SessionFilterChain filterChain) throws Exception {
        log.info(filterChain.getSession() + " started");
        super.sessionStarted(filterChain);
    }

    public void sessionTimeout(SessionFilterChain filterChain) throws Exception {
        log.info(filterChain.getSession() + " timeout");
        super.sessionTimeout(filterChain);
    }

}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?