Class TestSplitLogger

java.lang.Object
org.jlab.logging.TestSplitLogger

public class TestSplitLogger extends Object
A simple class demonstrating how to use SplitLogger.

The SplitLogger class will send SEVERE and WARNING log messages to stderr, and all lower levels to stdout.

How to set the logging level:

A .properties file is necessary, which has the class name and desired log level; for example,

org.jlab.logging.TestSplitLogger.level = FINE
From high to low, the levels are: SEVERE, WARNING, INFO, CONFIG, FINE, FINER, FINEST.

There are some example .properties files you can use with this class, like so:

java \
  -Djava.util.logging.config.file=common-tools/clas-logging/src/main/resources/org/jlab/logging/TestSplitLogger.finest.properties \
  -cp ... \
  org.jlab.logging.TestSplitLogger
You may write your own .properties file, to control the logging level of all classes which use logging.
Author:
dilks
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected static final Logger
    logger instance for this class
  • Constructor Summary

    Constructors
    Constructor
    Description
    constructor: prints some messages to stdout, but not using the logger yet
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    main(String[] args)
    run the tests
    void
    test sending string literals
    void
    test sending a format string with parameters
    void
    test exception handling
    void
    test exception handling
    void
    test lazy evaluation. the slow function nap() will only run if the log level is FINEST.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • LOGGER

      protected static final Logger LOGGER
      logger instance for this class
  • Constructor Details

    • TestSplitLogger

      public TestSplitLogger()
      constructor: prints some messages to stdout, but not using the logger yet
  • Method Details

    • test1

      public void test1()
      test sending string literals
    • test2

      public void test2()
      test sending a format string with parameters
    • test3

      public void test3()
      test exception handling
    • test4

      public void test4()
      test exception handling
    • test5

      public void test5()
      test lazy evaluation. the slow function nap() will only run if the log level is FINEST.
    • main

      public static void main(String[] args)
      run the tests
      Parameters:
      args - unused