Class TraceSystem

java.lang.Object
org.h2.message.TraceSystem

public class TraceSystem extends Object
The trace mechanism is the logging facility of this database. There is usually one trace system per database. It is called 'trace' because the term 'log' is already used in the database domain and means 'transaction log'. It is possible to write after close was called, but that means for each write the file will be opened and closed again (which is slower).
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    This trace level means all type of messages should be written, but instead of using the trace file the messages should be written to SLF4J.
    static final int
    This trace level means all type of messages should be written.
    static final int
    The default level for file trace messages.
    static final int
    The default level for system out trace messages.
    static final int
    This trace level means only errors should be written.
    static final int
    This trace level means errors and informational messages should be written.
    static final int
    This trace level means nothing should be written.
    static final int
    The parent trace level should be used.
  • Constructor Summary

    Constructors
    Constructor
    Description
    TraceSystem(String fileName)
    Create a new trace system object.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Close the writers, and the files if required.
    int
     
    getTrace(int moduleId)
    Get or create a trace object for this module id.
    getTrace(String module)
    Create a trace object for this module.
    boolean
    isEnabled(int level)
     
    void
    Set the trace file name.
    void
    setLevelFile(int level)
    Set the file trace level.
    void
    setLevelSystemOut(int level)
    Set the trace level to use for System.out
    void
    setMaxFileSize(int max)
    Set the maximum trace file size in bytes.
    void
     
    void
    Set the print stream to use instead of System.out.
    void
    write(int level, int moduleId, String s, Throwable t)
     
    void
    write(int level, String module, String s, Throwable t)
     

    Methods inherited from class java.lang.Object

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

    • PARENT

      public static final int PARENT
      The parent trace level should be used.
      See Also:
    • OFF

      public static final int OFF
      This trace level means nothing should be written.
      See Also:
    • ERROR

      public static final int ERROR
      This trace level means only errors should be written.
      See Also:
    • INFO

      public static final int INFO
      This trace level means errors and informational messages should be written.
      See Also:
    • DEBUG

      public static final int DEBUG
      This trace level means all type of messages should be written.
      See Also:
    • ADAPTER

      public static final int ADAPTER
      This trace level means all type of messages should be written, but instead of using the trace file the messages should be written to SLF4J.
      See Also:
    • DEFAULT_TRACE_LEVEL_SYSTEM_OUT

      public static final int DEFAULT_TRACE_LEVEL_SYSTEM_OUT
      The default level for system out trace messages.
      See Also:
    • DEFAULT_TRACE_LEVEL_FILE

      public static final int DEFAULT_TRACE_LEVEL_FILE
      The default level for file trace messages.
      See Also:
  • Constructor Details

    • TraceSystem

      public TraceSystem(String fileName)
      Create a new trace system object.
      Parameters:
      fileName - the file name
  • Method Details

    • setSysOut

      public void setSysOut(PrintStream out)
      Set the print stream to use instead of System.out.
      Parameters:
      out - the new print stream
    • getTrace

      public Trace getTrace(int moduleId)
      Get or create a trace object for this module id. Trace modules with id are cached.
      Parameters:
      moduleId - module id
      Returns:
      the trace object
    • getTrace

      public Trace getTrace(String module)
      Create a trace object for this module. Trace modules with names are not cached.
      Parameters:
      module - the module name
      Returns:
      the trace object
    • isEnabled

      public boolean isEnabled(int level)
    • setFileName

      public void setFileName(String name)
      Set the trace file name.
      Parameters:
      name - the file name
    • setMaxFileSize

      public void setMaxFileSize(int max)
      Set the maximum trace file size in bytes.
      Parameters:
      max - the maximum size
    • setLevelSystemOut

      public void setLevelSystemOut(int level)
      Set the trace level to use for System.out
      Parameters:
      level - the new level
    • setLevelFile

      public void setLevelFile(int level)
      Set the file trace level.
      Parameters:
      level - the new level
    • getLevelFile

      public int getLevelFile()
    • write

      public void write(int level, int moduleId, String s, Throwable t)
    • write

      public void write(int level, String module, String s, Throwable t)
    • close

      public void close()
      Close the writers, and the files if required. It is still possible to write after closing, however after each write the file is closed again (slowing down tracing).
    • setName

      public void setName(String name)