Class InternalAppender
java.lang.Object
org.apache.log4j.AppenderSkeleton
name.moore.kevin.ze.game.states.remote.InternalAppender
- All Implemented Interfaces:
org.apache.log4j.Appender,org.apache.log4j.spi.OptionHandler
public class InternalAppender
extends org.apache.log4j.AppenderSkeleton
This log4j appender is configurable AT RUNTIME by an application.
Configure in log4j with
log4j.appender.REMOTE=name.moore.kevin.ze.game.states.remote.InternalAppender
and then in application code
InternalAppender.setFunc( (f) ->{server.broadcast(f);} );
Logging, and hence the appender, is instantiated early before the function can be set, so we check for null. This means early logging messages wont make it to the function and will be lost.
Since the appender can receive all logging messages fired by the application it allows the application to (for instance) redirect that logging elsewhere or process that data to 'read its own internal thinking'
DONT use Logging here - it will setup a feedback loop as log messages come back here to be broadcast...
- Author:
- Kevin Moore
<dev@kevin.moore.name>
-
Field Summary
FieldsFields inherited from class org.apache.log4j.AppenderSkeleton
closed, errorHandler, headFilter, layout, name, tailFilter, threshold -
Constructor Summary
Constructors -
Method Summary
Methods inherited from class org.apache.log4j.AppenderSkeleton
activateOptions, addFilter, clearFilters, doAppend, finalize, getErrorHandler, getFilter, getFirstFilter, getLayout, getName, getThreshold, isAsSevereAsThreshold, setErrorHandler, setLayout, setName, setThreshold
-
Field Details
-
func
-
-
Constructor Details
-
InternalAppender
public InternalAppender()
-
-
Method Details
-
getFunc
- Returns:
-
setFunc
Provide a function to do something with the LoggingEvents that come to this appender.- Parameters:
f-
-
append
protected void append(org.apache.log4j.spi.LoggingEvent le)- Specified by:
appendin classorg.apache.log4j.AppenderSkeleton
-
close
public void close() -
requiresLayout
public boolean requiresLayout()
-