Class TraceWriterAdapter

  • All Implemented Interfaces:
    TraceWriter

    public class TraceWriterAdapter
    extends java.lang.Object
    implements TraceWriter
    This adapter sends log output to SLF4J. SLF4J supports multiple implementations such as Logback, Log4j, Jakarta Commons Logging (JCL), JDK 1.4 logging, x4juli, and Simple Log. To use SLF4J, you need to add the required jar files to the classpath, and set the trace level to 4 when opening a database:
     jdbc:h2:˜/test;TRACE_LEVEL_FILE=4
     
    The logger name is 'h2database'.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private org.slf4j.Logger logger  
      private java.lang.String name  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean isEnabled​(int level)
      Check the given trace / log level is enabled.
      void setName​(java.lang.String name)
      Set the name of the database or trace object.
      void write​(int level, int moduleId, java.lang.String s, java.lang.Throwable t)
      Write a message.
      void write​(int level, java.lang.String module, java.lang.String s, java.lang.Throwable t)
      Write a message.
      • Methods inherited from class java.lang.Object

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

      • name

        private java.lang.String name
      • logger

        private final org.slf4j.Logger logger
    • Constructor Detail

      • TraceWriterAdapter

        public TraceWriterAdapter()
    • Method Detail

      • setName

        public void setName​(java.lang.String name)
        Description copied from interface: TraceWriter
        Set the name of the database or trace object.
        Specified by:
        setName in interface TraceWriter
        Parameters:
        name - the new name
      • isEnabled

        public boolean isEnabled​(int level)
        Description copied from interface: TraceWriter
        Check the given trace / log level is enabled.
        Specified by:
        isEnabled in interface TraceWriter
        Parameters:
        level - the level
        Returns:
        true if the level is enabled
      • write

        public void write​(int level,
                          int moduleId,
                          java.lang.String s,
                          java.lang.Throwable t)
        Description copied from interface: TraceWriter
        Write a message.
        Specified by:
        write in interface TraceWriter
        Parameters:
        level - the trace level
        moduleId - the id of the module
        s - the message
        t - the exception (may be null)
      • write

        public void write​(int level,
                          java.lang.String module,
                          java.lang.String s,
                          java.lang.Throwable t)
        Description copied from interface: TraceWriter
        Write a message.
        Specified by:
        write in interface TraceWriter
        Parameters:
        level - the trace level
        module - the name of the module
        s - the message
        t - the exception (may be null)