Package com.yahoo.log

Class LogSetup


  • public class LogSetup
    extends java.lang.Object
    Sets up Vespa logging. Call a setup method to set up this.
    Author:
    Bjorn Borud, arnej27959
    • Constructor Summary

      Constructors 
      Constructor Description
      LogSetup()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void cleanup()
      Returns the log handler set up by this class
      static void clearHandlers()  
      static com.yahoo.log.VespaLogHandler getLogHandler()
      Returns the log handler set up by this class
      static java.util.Timer getTaskRunner()
      A global task thread
      static void initVespaLogging​(java.lang.String programName)
      Every Vespa application should call initVespaLogging exactly one time.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • LogSetup

        public LogSetup()
    • Method Detail

      • getTaskRunner

        public static java.util.Timer getTaskRunner()
        A global task thread
      • clearHandlers

        public static void clearHandlers()
      • initVespaLogging

        public static void initVespaLogging​(java.lang.String programName)
        Every Vespa application should call initVespaLogging exactly one time. This should be done from the main() method or from a static initializer in the main class. The library will pick up the environment variables usually set by the Vespa config-sentinel (VESPA_LOG_LEVEL, VESPA_LOG_TARGET, VESPA_SERVICE_NAME, VESPA_LOG_CONTROL_DIR) but it's possible to override these by setting system properties before calling initVespaLogging. This may be useful for unit testing etc:
        System.setProperty("vespa.log.level", "all")
        System.setProperty("vespa.log.target", "file:foo.log")
        System.setProperty("vespa.service.name", "my.name")
        System.setProperty("vespa.log.control.dir", ".")
        System.setProperty("vespa.log.control.file", "my.logcontrol")
        vespa.log.control.file is used if it's set, otherwise it's vespa.log.control.dir + "/" + vespa.service.name + ".logcontrol" if both of those variables are set, otherwise there will be no runtime log control.
        Parameters:
        programName - the name of the program that is running; this is added as a prefix to the logger name to form the "component" part of the log message. (Usually the logger name is the name of the class that logs something, so the programName should be kept short and simple.)
      • getLogHandler

        public static com.yahoo.log.VespaLogHandler getLogHandler()
        Returns the log handler set up by this class
      • cleanup

        public static void cleanup()
        Returns the log handler set up by this class