Package hec.io

Class PeriodicLogger

java.lang.Object
java.util.TimerTask
hec.io.PeriodicLogger
All Implemented Interfaces:
Runnable

public final class PeriodicLogger extends TimerTask
A scheduled logger that will log every 15 minutes. To set the message, define the property PeriodicLogger.message (for example, -DPeriodicLogger.message="some message here")
  • Field Details

  • Method Details

    • run

      public void run()
      Log a message. This is intended to only be called by the periodic executor service.
      Specified by:
      run in interface Runnable
      Specified by:
      run in class TimerTask
    • shutdown

      public void shutdown()
      Shutdown the executor service and stop logging messages
    • runAtFixedRate

      public static PeriodicLogger runAtFixedRate(boolean isDaemon)
      Create a periodic logger and schedule it to run every 15 minutes starting at the nearest 15 minute interval. If this method is run at 10:07 am, the logger will first run at 10:15 am, then 10:30 am, etc until either shutdown() is called on the returned PeriodicLogger or the JVM shuts down (if isDaemon is true)
      Parameters:
      isDaemon - true if the executor service should create a daemon thread. If true, the executor service will not keep the JVM running. If false, the executor service will keep the JVM running, even if all other threads have terminated. It should not, however, keep the JVM running after System.exit(int) is called.
      Returns:
      A periodic logger that will run every 15 minutes.