Class ChainsawAppender

  • All Implemented Interfaces:
    org.apache.log4j.Appender, org.apache.log4j.spi.OptionHandler

    public class ChainsawAppender
    extends org.apache.log4j.AppenderSkeleton
    ChainsawAppender receives LoggingEvents from the local Log4J environment, and appends them into a model that can be used inside a Swing GUI
    Version:
    1.0
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private org.apache.log4j.Appender appender  
      private java.lang.String application  
      private java.lang.String hostname  
      private static ChainsawAppender sSharedAppender
      The in-JVM singleton instance of the ChainsawAppender.
      private java.lang.String viewerClassname
      The classname of the viewer to create to view the events.
      • Fields inherited from class org.apache.log4j.AppenderSkeleton

        closed, errorHandler, headFilter, layout, name, tailFilter, threshold
    • Constructor Summary

      Constructors 
      Constructor Description
      ChainsawAppender()
      Constructor, initialises the singleton instance of the appender
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void activateOptions()
      Instantiates and activates an instance of a ChainsawViewer to view the contents of this appender.
      protected void append​(org.apache.log4j.spi.LoggingEvent aEvent)
      Appends the event
      void close()
      Close does nothing
      org.apache.log4j.Appender getAppender()  
      java.lang.String getApplication()
      Returns value of the Application option.
      (package private) static ChainsawAppender getInstance()
      Return the singleton instance of the ChainsawAppender, it should only be initialised once.
      java.lang.String getViewerClass()
      Gets the viewer class to use to view the events.
      boolean requiresLayout()
      This appender does not require layout and so return false
      void setAppender​(org.apache.log4j.Appender appender)  
      void setApplication​(java.lang.String lapp)
      The Application option takes a string value which should be the name of the application getting logged
      void setViewerClass​(java.lang.String classname)
      Sets the viewer class to use to view the events.
      • Methods inherited from class org.apache.log4j.AppenderSkeleton

        addFilter, clearFilters, doAppend, finalize, getErrorHandler, getFilter, getFirstFilter, getLayout, getName, getThreshold, isAsSevereAsThreshold, setErrorHandler, setLayout, setName, setThreshold
      • Methods inherited from class java.lang.Object

        clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • appender

        private org.apache.log4j.Appender appender
      • sSharedAppender

        private static ChainsawAppender sSharedAppender
        The in-JVM singleton instance of the ChainsawAppender.

        If somehow Log4j initialises more than one, then the first one to initialise wins!

      • viewerClassname

        private java.lang.String viewerClassname
        The classname of the viewer to create to view the events.
      • hostname

        private java.lang.String hostname
      • application

        private java.lang.String application
    • Constructor Detail

      • ChainsawAppender

        public ChainsawAppender()
        Constructor, initialises the singleton instance of the appender
    • Method Detail

      • getInstance

        static ChainsawAppender getInstance()
        Return the singleton instance of the ChainsawAppender, it should only be initialised once.
        Returns:
        the One and only instance of the ChainsawAppender that is allowed to be referenced by the GUI
      • requiresLayout

        public boolean requiresLayout()
        This appender does not require layout and so return false
        Returns:
        false and only false
      • getAppender

        public org.apache.log4j.Appender getAppender()
      • setAppender

        public void setAppender​(org.apache.log4j.Appender appender)
      • append

        protected void append​(org.apache.log4j.spi.LoggingEvent aEvent)
        Appends the event
        Specified by:
        append in class org.apache.log4j.AppenderSkeleton
        Parameters:
        aEvent - the LoggingEvent to append
      • activateOptions

        public void activateOptions()
        Instantiates and activates an instance of a ChainsawViewer to view the contents of this appender.
        Specified by:
        activateOptions in interface org.apache.log4j.spi.OptionHandler
        Overrides:
        activateOptions in class org.apache.log4j.AppenderSkeleton
      • close

        public void close()
        Close does nothing
      • setViewerClass

        public void setViewerClass​(java.lang.String classname)
        Sets the viewer class to use to view the events. The class must implement the ChainsawViewer interface.
        Parameters:
        classname - The class name of the viewer class.
      • getViewerClass

        public java.lang.String getViewerClass()
        Gets the viewer class to use to view the events.
        Returns:
        The class name of the viewer class.
      • setApplication

        public void setApplication​(java.lang.String lapp)
        The Application option takes a string value which should be the name of the application getting logged
      • getApplication

        public java.lang.String getApplication()
        Returns value of the Application option.