Class Slf4jSQLLogger

java.lang.Object
org.apache.cayenne.log.Slf4jSQLLogger
All Implemented Interfaces:
SQLLogger

public class Slf4jSQLLogger extends Object implements SQLLogger
A SQLLogger that emits compact, single-line messages through slf4j-api under the fixed logger name cayenne-sql.
Since:
5.0
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final int
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Slf4jSQLLogger(RuntimeProperties runtimeProperties)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Returns true if statement logging is enabled.
    void
    logAlsoSelect(int rowCount)
    Logs a select count continuation line for the statement whose header was already logged.
    void
    logAlsoUpdate(int rowCount)
    Logs an update count continuation line for the statement whose header was already logged.
    void
    logMessage(String message)
    Logs an arbitrary message, such as DDL, PK-generation SQL, or adapter-detection notes.
    void
    logQueryError(TranslatedStatement statement, Throwable error, long durationMillis)
    Logs, at the ERROR level, the statement that was in progress when a query exception occurred: SQL + bind:[...] + the error message, followed by a trailing time_ms:N block with the time elapsed until the failure.
    void
    logSelect(TranslatedStatement statement, int rowCount, long durationMillis)
    Logs the main line for a statement that returned a result set: SQL + bind:[...] + selected:N, followed by a trailing time_ms:N block with the statement's execution time.
    void
    Logs a transaction commit boundary (emitted at DEBUG level).
    void
    Logs a transaction rollback boundary (emitted at DEBUG level).
    void
    Logs a transaction start boundary (emitted at DEBUG level).
    void
    logUpdate(TranslatedStatement statement, int rowCount, List<? extends Map<String,?>> generatedKeys, long durationMillis)
    Logs the main line for a statement that performed an update: SQL + bind:[...] + updated:N, optionally followed by a generated:[...] block listing any database-generated keys, and a trailing time_ms:N block with the statement's execution time.

    Methods inherited from class java.lang.Object

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

    • batchRowThreshold

      protected final int batchRowThreshold
  • Constructor Details

  • Method Details

    • isEnabled

      public boolean isEnabled()
      Description copied from interface: SQLLogger
      Returns true if statement logging is enabled. Callers should skip the work of assembling results when this returns false.
      Specified by:
      isEnabled in interface SQLLogger
    • logSelect

      public void logSelect(TranslatedStatement statement, int rowCount, long durationMillis)
      Description copied from interface: SQLLogger
      Logs the main line for a statement that returned a result set: SQL + bind:[...] + selected:N, followed by a trailing time_ms:N block with the statement's execution time.
      Specified by:
      logSelect in interface SQLLogger
      Parameters:
      statement - the translated statement carrying SQL and bindings
      rowCount - the number of selected rows
      durationMillis - the statement's execution time in milliseconds
    • logUpdate

      public void logUpdate(TranslatedStatement statement, int rowCount, List<? extends Map<String,?>> generatedKeys, long durationMillis)
      Description copied from interface: SQLLogger
      Logs the main line for a statement that performed an update: SQL + bind:[...] + updated:N, optionally followed by a generated:[...] block listing any database-generated keys, and a trailing time_ms:N block with the statement's execution time.
      Specified by:
      logUpdate in interface SQLLogger
      Parameters:
      statement - the translated statement carrying SQL and bindings
      rowCount - the number of updated rows
      generatedKeys - the database-generated keys of the inserted rows, or an empty list if none
      durationMillis - the statement's execution time in milliseconds
    • logQueryError

      public void logQueryError(TranslatedStatement statement, Throwable error, long durationMillis)
      Description copied from interface: SQLLogger
      Logs, at the ERROR level, the statement that was in progress when a query exception occurred: SQL + bind:[...] + the error message, followed by a trailing time_ms:N block with the time elapsed until the failure.
      Specified by:
      logQueryError in interface SQLLogger
      Parameters:
      statement - the translated statement carrying SQL and bindings
      error - the exception thrown while executing the statement
      durationMillis - the time in milliseconds elapsed until the failure
    • logAlsoSelect

      public void logAlsoSelect(int rowCount)
      Description copied from interface: SQLLogger
      Logs a select count continuation line for the statement whose header was already logged.
      Specified by:
      logAlsoSelect in interface SQLLogger
    • logAlsoUpdate

      public void logAlsoUpdate(int rowCount)
      Description copied from interface: SQLLogger
      Logs an update count continuation line for the statement whose header was already logged.
      Specified by:
      logAlsoUpdate in interface SQLLogger
    • logTransactionStart

      public void logTransactionStart()
      Description copied from interface: SQLLogger
      Logs a transaction start boundary (emitted at DEBUG level).
      Specified by:
      logTransactionStart in interface SQLLogger
    • logTransactionCommit

      public void logTransactionCommit()
      Description copied from interface: SQLLogger
      Logs a transaction commit boundary (emitted at DEBUG level).
      Specified by:
      logTransactionCommit in interface SQLLogger
    • logTransactionRollback

      public void logTransactionRollback()
      Description copied from interface: SQLLogger
      Logs a transaction rollback boundary (emitted at DEBUG level).
      Specified by:
      logTransactionRollback in interface SQLLogger
    • logMessage

      public void logMessage(String message)
      Description copied from interface: SQLLogger
      Logs an arbitrary message, such as DDL, PK-generation SQL, or adapter-detection notes.
      Specified by:
      logMessage in interface SQLLogger