Package org.apache.log4j.rewrite
Class RewriteAppender
- java.lang.Object
-
- org.apache.log4j.AppenderSkeleton
-
- org.apache.log4j.rewrite.RewriteAppender
-
- All Implemented Interfaces:
org.apache.log4j.Appender
,org.apache.log4j.spi.AppenderAttachable
,org.apache.log4j.spi.OptionHandler
,org.apache.log4j.xml.UnrecognizedElementHandler
public class RewriteAppender extends org.apache.log4j.AppenderSkeleton implements org.apache.log4j.spi.AppenderAttachable, org.apache.log4j.xml.UnrecognizedElementHandler
This appender forwards a logging request to another appender after possibly rewriting the logging event.This appender (with the appropriate policy) replaces the MapFilter, PropertyFilter and ReflectionFilter from log4j 1.3.
-
-
Constructor Summary
Constructors Constructor Description RewriteAppender()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addAppender(org.apache.log4j.Appender newAppender)
Add appender.protected void
append(org.apache.log4j.spi.LoggingEvent event)
void
close()
Close thisAsyncAppender
by interrupting the dispatcher thread which will process all pending events before exiting.Enumeration
getAllAppenders()
Get iterator over attached appenders.org.apache.log4j.Appender
getAppender(String name)
Get appender by name.boolean
isAttached(org.apache.log4j.Appender appender)
Determines if specified appender is attached.boolean
parseUnrecognizedElement(Element element, Properties props)
void
removeAllAppenders()
Removes and closes all attached appenders.void
removeAppender(String name)
Remove appender by name.void
removeAppender(org.apache.log4j.Appender appender)
Removes an appender.boolean
requiresLayout()
void
setRewritePolicy(RewritePolicy rewritePolicy)
-
-
-
Method Detail
-
append
protected void append(org.apache.log4j.spi.LoggingEvent event)
- Specified by:
append
in classorg.apache.log4j.AppenderSkeleton
-
addAppender
public void addAppender(org.apache.log4j.Appender newAppender)
Add appender.- Specified by:
addAppender
in interfaceorg.apache.log4j.spi.AppenderAttachable
- Parameters:
newAppender
- appender to add, may not be null.
-
getAllAppenders
public Enumeration getAllAppenders()
Get iterator over attached appenders.- Specified by:
getAllAppenders
in interfaceorg.apache.log4j.spi.AppenderAttachable
- Returns:
- iterator or null if no attached appenders.
-
getAppender
public org.apache.log4j.Appender getAppender(String name)
Get appender by name.- Specified by:
getAppender
in interfaceorg.apache.log4j.spi.AppenderAttachable
- Parameters:
name
- name, may not be null.- Returns:
- matching appender or null.
-
close
public void close()
Close thisAsyncAppender
by interrupting the dispatcher thread which will process all pending events before exiting.- Specified by:
close
in interfaceorg.apache.log4j.Appender
-
isAttached
public boolean isAttached(org.apache.log4j.Appender appender)
Determines if specified appender is attached.- Specified by:
isAttached
in interfaceorg.apache.log4j.spi.AppenderAttachable
- Parameters:
appender
- appender.- Returns:
- true if attached.
-
requiresLayout
public boolean requiresLayout()
- Specified by:
requiresLayout
in interfaceorg.apache.log4j.Appender
-
removeAllAppenders
public void removeAllAppenders()
Removes and closes all attached appenders.- Specified by:
removeAllAppenders
in interfaceorg.apache.log4j.spi.AppenderAttachable
-
removeAppender
public void removeAppender(org.apache.log4j.Appender appender)
Removes an appender.- Specified by:
removeAppender
in interfaceorg.apache.log4j.spi.AppenderAttachable
- Parameters:
appender
- appender to remove.
-
removeAppender
public void removeAppender(String name)
Remove appender by name.- Specified by:
removeAppender
in interfaceorg.apache.log4j.spi.AppenderAttachable
- Parameters:
name
- name.
-
setRewritePolicy
public void setRewritePolicy(RewritePolicy rewritePolicy)
-
parseUnrecognizedElement
public boolean parseUnrecognizedElement(Element element, Properties props) throws Exception
- Specified by:
parseUnrecognizedElement
in interfaceorg.apache.log4j.xml.UnrecognizedElementHandler
- Throws:
Exception
-
-