Package org.apache.mina.filter.logging
Class LoggingFilter
- java.lang.Object
-
- org.apache.mina.core.filterchain.IoFilterAdapter
-
- org.apache.mina.filter.logging.LoggingFilter
-
- All Implemented Interfaces:
IoFilter
public class LoggingFilter extends IoFilterAdapter
Logs MINA protocol events. Each event can be tuned to use a different level based on the user's specific requirements. Methods are in place that allow the user to use either the get or set method for each event and pass in theIoEventTypeand theLogLevel. By default, all events are logged to theLogLevel.INFOlevel exceptIoFilterAdapter.exceptionCaught(IoFilter.NextFilter, IoSession, Throwable), which is logged toLogLevel.WARN.- Author:
- Apache MINA Project
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.mina.core.filterchain.IoFilter
IoFilter.NextFilter
-
-
Constructor Summary
Constructors Constructor Description LoggingFilter()Default Constructor.LoggingFilter(Class<?> clazz)Create a new NoopFilter using a class nameLoggingFilter(String name)Create a new NoopFilter using a name
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidexceptionCaught(IoFilter.NextFilter nextFilter, IoSession session, Throwable cause)FiltersIoHandler.exceptionCaught(IoSession,Throwable)event.LogLevelgetExceptionCaughtLogLevel()Get the LogLevel for the ExceptionCaught event.LogLevelgetMessageReceivedLogLevel()Get the LogLevel for the MessageReceived event.LogLevelgetMessageSentLogLevel()Get the LogLevel for the MessageSent event.StringgetName()LogLevelgetSessionClosedLogLevel()Get the LogLevel for the SessionClosed event.LogLevelgetSessionCreatedLogLevel()Get the LogLevel for the SessionCreated event.LogLevelgetSessionIdleLogLevel()Get the LogLevel for the SessionIdle event.LogLevelgetSessionOpenedLogLevel()Get the LogLevel for the SessionOpened event.voidmessageReceived(IoFilter.NextFilter nextFilter, IoSession session, Object message)FiltersIoHandler.messageReceived(IoSession,Object)event.voidmessageSent(IoFilter.NextFilter nextFilter, IoSession session, WriteRequest writeRequest)FiltersIoHandler.messageSent(IoSession,Object)event.voidsessionClosed(IoFilter.NextFilter nextFilter, IoSession session)FiltersIoHandler.sessionClosed(IoSession)event.voidsessionCreated(IoFilter.NextFilter nextFilter, IoSession session)FiltersIoHandler.sessionCreated(IoSession)event.voidsessionIdle(IoFilter.NextFilter nextFilter, IoSession session, IdleStatus status)FiltersIoHandler.sessionIdle(IoSession,IdleStatus)event.voidsessionOpened(IoFilter.NextFilter nextFilter, IoSession session)FiltersIoHandler.sessionOpened(IoSession)event.voidsetExceptionCaughtLogLevel(LogLevel level)Set the LogLevel for the ExceptionCaught event.voidsetMessageReceivedLogLevel(LogLevel level)Set the LogLevel for the MessageReceived event.voidsetMessageSentLogLevel(LogLevel level)Set the LogLevel for the MessageSent event.voidsetSessionClosedLogLevel(LogLevel level)Set the LogLevel for the SessionClosed event.voidsetSessionCreatedLogLevel(LogLevel level)Set the LogLevel for the SessionCreated event.voidsetSessionIdleLogLevel(LogLevel level)Set the LogLevel for the SessionIdle event.voidsetSessionOpenedLogLevel(LogLevel level)Set the LogLevel for the SessionOpened event.-
Methods inherited from class org.apache.mina.core.filterchain.IoFilterAdapter
destroy, event, filterClose, filterWrite, init, inputClosed, onPostAdd, onPostRemove, onPreAdd, onPreRemove, toString
-
-
-
-
Constructor Detail
-
LoggingFilter
public LoggingFilter()
Default Constructor.
-
LoggingFilter
public LoggingFilter(Class<?> clazz)
Create a new NoopFilter using a class name- Parameters:
clazz- the cass which name will be used to create the logger
-
LoggingFilter
public LoggingFilter(String name)
Create a new NoopFilter using a name- Parameters:
name- the name used to create the logger. If null, will default to "NoopFilter"
-
-
Method Detail
-
getName
public String getName()
- Returns:
- The logger's name
-
exceptionCaught
public void exceptionCaught(IoFilter.NextFilter nextFilter, IoSession session, Throwable cause) throws Exception
FiltersIoHandler.exceptionCaught(IoSession,Throwable)event.- Specified by:
exceptionCaughtin interfaceIoFilter- Overrides:
exceptionCaughtin classIoFilterAdapter- Parameters:
nextFilter- theIoFilter.NextFilterfor this filter. You can reuse this object until this filter is removed from the chain.session- TheIoSessionwhich has received this eventcause- The exception that cause this event to be received- Throws:
Exception- If an error occurred while processing the event
-
messageReceived
public void messageReceived(IoFilter.NextFilter nextFilter, IoSession session, Object message) throws Exception
FiltersIoHandler.messageReceived(IoSession,Object)event.- Specified by:
messageReceivedin interfaceIoFilter- Overrides:
messageReceivedin classIoFilterAdapter- Parameters:
nextFilter- theIoFilter.NextFilterfor this filter. You can reuse this object until this filter is removed from the chain.session- TheIoSessionwhich has received this eventmessage- The received message- Throws:
Exception- If an error occurred while processing the event
-
messageSent
public void messageSent(IoFilter.NextFilter nextFilter, IoSession session, WriteRequest writeRequest) throws Exception
FiltersIoHandler.messageSent(IoSession,Object)event.- Specified by:
messageSentin interfaceIoFilter- Overrides:
messageSentin classIoFilterAdapter- Parameters:
nextFilter- theIoFilter.NextFilterfor this filter. You can reuse this object until this filter is removed from the chain.session- TheIoSessionwhich has received this eventwriteRequest- TheWriteRequestthat contains the sent message- Throws:
Exception- If an error occurred while processing the event
-
sessionCreated
public void sessionCreated(IoFilter.NextFilter nextFilter, IoSession session) throws Exception
FiltersIoHandler.sessionCreated(IoSession)event.- Specified by:
sessionCreatedin interfaceIoFilter- Overrides:
sessionCreatedin classIoFilterAdapter- Parameters:
nextFilter- theIoFilter.NextFilterfor this filter. You can reuse this object until this filter is removed from the chain.session- TheIoSessionwhich has received this event- Throws:
Exception- If an error occurred while processing the event
-
sessionOpened
public void sessionOpened(IoFilter.NextFilter nextFilter, IoSession session) throws Exception
FiltersIoHandler.sessionOpened(IoSession)event.- Specified by:
sessionOpenedin interfaceIoFilter- Overrides:
sessionOpenedin classIoFilterAdapter- Parameters:
nextFilter- theIoFilter.NextFilterfor this filter. You can reuse this object until this filter is removed from the chain.session- TheIoSessionwhich has received this event- Throws:
Exception- If an error occurred while processing the event
-
sessionIdle
public void sessionIdle(IoFilter.NextFilter nextFilter, IoSession session, IdleStatus status) throws Exception
FiltersIoHandler.sessionIdle(IoSession,IdleStatus)event.- Specified by:
sessionIdlein interfaceIoFilter- Overrides:
sessionIdlein classIoFilterAdapter- Parameters:
nextFilter- theIoFilter.NextFilterfor this filter. You can reuse this object until this filter is removed from the chain.session- TheIoSessionwhich has received this eventstatus- TheIdleStatustype- Throws:
Exception- If an error occurred while processing the event
-
sessionClosed
public void sessionClosed(IoFilter.NextFilter nextFilter, IoSession session) throws Exception
FiltersIoHandler.sessionClosed(IoSession)event.- Specified by:
sessionClosedin interfaceIoFilter- Overrides:
sessionClosedin classIoFilterAdapter- Parameters:
nextFilter- theIoFilter.NextFilterfor this filter. You can reuse this object until this filter is removed from the chain.session- TheIoSessionwhich has received this event- Throws:
Exception- If an error occurred while processing the event
-
setExceptionCaughtLogLevel
public void setExceptionCaughtLogLevel(LogLevel level)
Set the LogLevel for the ExceptionCaught event.- Parameters:
level- The LogLevel to set
-
getExceptionCaughtLogLevel
public LogLevel getExceptionCaughtLogLevel()
Get the LogLevel for the ExceptionCaught event.- Returns:
- The LogLevel for the ExceptionCaught eventType
-
setMessageReceivedLogLevel
public void setMessageReceivedLogLevel(LogLevel level)
Set the LogLevel for the MessageReceived event.- Parameters:
level- The LogLevel to set
-
getMessageReceivedLogLevel
public LogLevel getMessageReceivedLogLevel()
Get the LogLevel for the MessageReceived event.- Returns:
- The LogLevel for the MessageReceived eventType
-
setMessageSentLogLevel
public void setMessageSentLogLevel(LogLevel level)
Set the LogLevel for the MessageSent event.- Parameters:
level- The LogLevel to set
-
getMessageSentLogLevel
public LogLevel getMessageSentLogLevel()
Get the LogLevel for the MessageSent event.- Returns:
- The LogLevel for the MessageSent eventType
-
setSessionCreatedLogLevel
public void setSessionCreatedLogLevel(LogLevel level)
Set the LogLevel for the SessionCreated event.- Parameters:
level- The LogLevel to set
-
getSessionCreatedLogLevel
public LogLevel getSessionCreatedLogLevel()
Get the LogLevel for the SessionCreated event.- Returns:
- The LogLevel for the SessionCreated eventType
-
setSessionOpenedLogLevel
public void setSessionOpenedLogLevel(LogLevel level)
Set the LogLevel for the SessionOpened event.- Parameters:
level- The LogLevel to set
-
getSessionOpenedLogLevel
public LogLevel getSessionOpenedLogLevel()
Get the LogLevel for the SessionOpened event.- Returns:
- The LogLevel for the SessionOpened eventType
-
setSessionIdleLogLevel
public void setSessionIdleLogLevel(LogLevel level)
Set the LogLevel for the SessionIdle event.- Parameters:
level- The LogLevel to set
-
getSessionIdleLogLevel
public LogLevel getSessionIdleLogLevel()
Get the LogLevel for the SessionIdle event.- Returns:
- The LogLevel for the SessionIdle eventType
-
setSessionClosedLogLevel
public void setSessionClosedLogLevel(LogLevel level)
Set the LogLevel for the SessionClosed event.- Parameters:
level- The LogLevel to set
-
getSessionClosedLogLevel
public LogLevel getSessionClosedLogLevel()
Get the LogLevel for the SessionClosed event.- Returns:
- The LogLevel for the SessionClosed eventType
-
-