Class SoundAppender

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

    public final class SoundAppender
    extends org.apache.log4j.AppenderSkeleton
    This class is equivalent to org.apache.log4j.varia.SoundAppender except for a package change to aid in use with OSGi. Plays a sound clip created using Applet.newAudioClip when an event is received. If the audio format is not supported, a message stating the SoundAppender could not be initialized is logged. Use a filter in combination with this appender to control when the appender is triggered. For example, in the appender definition, include a LevelMatchFilter configured to accept WARN or greater, followed by a DenyAllFilter.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.lang.String audioURL  
      private java.applet.AudioClip clip  
      • Fields inherited from class org.apache.log4j.AppenderSkeleton

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

      Constructors 
      Constructor Description
      SoundAppender()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void activateOptions()
      Attempt to initialize the appender by creating a reference to an AudioClip.
      protected void append​(org.apache.log4j.spi.LoggingEvent event)
      Play the sound if an event is being processed
      void close()  
      java.lang.String getAudioURL()
      Accessor
      boolean requiresLayout()
      Gets whether appender requires a layout.
      void setAudioURL​(java.lang.String audioURL)
      Mutator - common format for a file-based url: file:///c:/path/someaudioclip.wav
      • 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

      • clip

        private java.applet.AudioClip clip
      • audioURL

        private java.lang.String audioURL
    • Constructor Detail

      • SoundAppender

        public SoundAppender()
    • Method Detail

      • activateOptions

        public void activateOptions()
        Attempt to initialize the appender by creating a reference to an AudioClip. Will log a message if format is not supported, file not found, etc.
        Specified by:
        activateOptions in interface org.apache.log4j.spi.OptionHandler
        Overrides:
        activateOptions in class org.apache.log4j.AppenderSkeleton
      • getAudioURL

        public java.lang.String getAudioURL()
        Accessor
        Returns:
        audio file
      • setAudioURL

        public void setAudioURL​(java.lang.String audioURL)
        Mutator - common format for a file-based url: file:///c:/path/someaudioclip.wav
        Parameters:
        audioURL -
      • append

        protected void append​(org.apache.log4j.spi.LoggingEvent event)
        Play the sound if an event is being processed
        Specified by:
        append in class org.apache.log4j.AppenderSkeleton
      • close

        public void close()
      • requiresLayout

        public boolean requiresLayout()
        Gets whether appender requires a layout.
        Returns:
        false