de.intarsys.tools.logging
Class ThreadFilter
java.lang.Object
de.intarsys.tools.logging.ThreadFilter
- All Implemented Interfaces:
- Filter
public class ThreadFilter
- extends Object
- implements Filter
Only accept log requests within a dedicated thread.
This is for example suitable in a scenario where a log should be associated
with a functor object but the functor is executed in different worker
threads. If the functor activates its filter upon entry, all activities can
be sent to the same log, even from different workers. In this case the thread
associated with the filter is switched with "activate" and "deactivate".
These methods should always be used in a "finally" style block.
Another scenario is where a thread has a dedicated task and all its
activities have to be logged. Here the thread is associated at startup and
remains the same.
ThreadFilter
public ThreadFilter(boolean activate)
activate
public boolean activate()
deactivate
public boolean deactivate()
isActive
public boolean isActive()
isLoggable
public boolean isLoggable(LogRecord record)
- Specified by:
isLoggable in interface Filter
Copyright © 2012 intarsys consulting GmbH. All Rights Reserved.