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 all 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 theIoEventType
and theLogLevel
. By default, all events are logged to theLogLevel.INFO
level 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 void
exceptionCaught(IoFilter.NextFilter nextFilter, IoSession session, Throwable cause)
FiltersIoHandler.exceptionCaught(IoSession,Throwable)
event.LogLevel
getExceptionCaughtLogLevel()
Get the LogLevel for the ExceptionCaught event.LogLevel
getMessageReceivedLogLevel()
Get the LogLevel for the MessageReceived event.LogLevel
getMessageSentLogLevel()
Get the LogLevel for the MessageSent event.String
getName()
LogLevel
getSessionClosedLogLevel()
Get the LogLevel for the SessionClosed event.LogLevel
getSessionCreatedLogLevel()
Get the LogLevel for the SessionCreated event.LogLevel
getSessionIdleLogLevel()
Get the LogLevel for the SessionIdle event.LogLevel
getSessionOpenedLogLevel()
Get the LogLevel for the SessionOpened event.void
messageReceived(IoFilter.NextFilter nextFilter, IoSession session, Object message)
FiltersIoHandler.messageReceived(IoSession,Object)
event.void
messageSent(IoFilter.NextFilter nextFilter, IoSession session, WriteRequest writeRequest)
FiltersIoHandler.messageSent(IoSession,Object)
event.void
sessionClosed(IoFilter.NextFilter nextFilter, IoSession session)
FiltersIoHandler.sessionClosed(IoSession)
event.void
sessionCreated(IoFilter.NextFilter nextFilter, IoSession session)
FiltersIoHandler.sessionCreated(IoSession)
event.void
sessionIdle(IoFilter.NextFilter nextFilter, IoSession session, IdleStatus status)
FiltersIoHandler.sessionIdle(IoSession,IdleStatus)
event.void
sessionOpened(IoFilter.NextFilter nextFilter, IoSession session)
FiltersIoHandler.sessionOpened(IoSession)
event.void
setExceptionCaughtLogLevel(LogLevel level)
Set the LogLevel for the ExceptionCaught event.void
setMessageReceivedLogLevel(LogLevel level)
Set the LogLevel for the MessageReceived event.void
setMessageSentLogLevel(LogLevel level)
Set the LogLevel for the MessageSent event.void
setSessionClosedLogLevel(LogLevel level)
Set the LogLevel for the SessionClosed event.void
setSessionCreatedLogLevel(LogLevel level)
Set the LogLevel for the SessionCreated event.void
setSessionIdleLogLevel(LogLevel level)
Set the LogLevel for the SessionIdle event.void
setSessionOpenedLogLevel(LogLevel level)
Set the LogLevel for the SessionOpened event.-
Methods inherited from class org.apache.mina.core.filterchain.IoFilterAdapter
destroy, 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
Description copied from class:IoFilterAdapter
FiltersIoHandler.exceptionCaught(IoSession,Throwable)
event.- Specified by:
exceptionCaught
in interfaceIoFilter
- Overrides:
exceptionCaught
in classIoFilterAdapter
- Parameters:
nextFilter
- theIoFilter.NextFilter
for this filter. You can reuse this object until this filter is removed from the chain.session
- TheIoSession
which 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
Description copied from class:IoFilterAdapter
FiltersIoHandler.messageReceived(IoSession,Object)
event.- Specified by:
messageReceived
in interfaceIoFilter
- Overrides:
messageReceived
in classIoFilterAdapter
- Parameters:
nextFilter
- theIoFilter.NextFilter
for this filter. You can reuse this object until this filter is removed from the chain.session
- TheIoSession
which 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
Description copied from class:IoFilterAdapter
FiltersIoHandler.messageSent(IoSession,Object)
event.- Specified by:
messageSent
in interfaceIoFilter
- Overrides:
messageSent
in classIoFilterAdapter
- Parameters:
nextFilter
- theIoFilter.NextFilter
for this filter. You can reuse this object until this filter is removed from the chain.session
- TheIoSession
which has received this eventwriteRequest
- TheWriteRequest
that 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
Description copied from class:IoFilterAdapter
FiltersIoHandler.sessionCreated(IoSession)
event.- Specified by:
sessionCreated
in interfaceIoFilter
- Overrides:
sessionCreated
in classIoFilterAdapter
- Parameters:
nextFilter
- theIoFilter.NextFilter
for this filter. You can reuse this object until this filter is removed from the chain.session
- TheIoSession
which 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
Description copied from class:IoFilterAdapter
FiltersIoHandler.sessionOpened(IoSession)
event.- Specified by:
sessionOpened
in interfaceIoFilter
- Overrides:
sessionOpened
in classIoFilterAdapter
- Parameters:
nextFilter
- theIoFilter.NextFilter
for this filter. You can reuse this object until this filter is removed from the chain.session
- TheIoSession
which 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
Description copied from class:IoFilterAdapter
FiltersIoHandler.sessionIdle(IoSession,IdleStatus)
event.- Specified by:
sessionIdle
in interfaceIoFilter
- Overrides:
sessionIdle
in classIoFilterAdapter
- Parameters:
nextFilter
- theIoFilter.NextFilter
for this filter. You can reuse this object until this filter is removed from the chain.session
- TheIoSession
which has received this eventstatus
- TheIdleStatus
type- Throws:
Exception
- If an error occurred while processing the event
-
sessionClosed
public void sessionClosed(IoFilter.NextFilter nextFilter, IoSession session) throws Exception
Description copied from class:IoFilterAdapter
FiltersIoHandler.sessionClosed(IoSession)
event.- Specified by:
sessionClosed
in interfaceIoFilter
- Overrides:
sessionClosed
in classIoFilterAdapter
- Parameters:
nextFilter
- theIoFilter.NextFilter
for this filter. You can reuse this object until this filter is removed from the chain.session
- TheIoSession
which 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
-
-