org.apache.cayenne.log

## Class Slf4jJdbcEventLogger

- java.lang.Object
- - org.apache.cayenne.log.Slf4jJdbcEventLogger

- All Implemented Interfaces:
    JdbcEventLogger
  Direct Known Subclasses:
    FormattedSlf4jJdbcEventLogger

      public class Slf4jJdbcEventLogger
      extends Object
      implements JdbcEventLogger

  A `JdbcEventLogger` built on top of slf4j-api logger.
  Since:
    3.1, 4.0 renamed from CommonsJdbcEventLogger to Slf4jJdbcEventLogger as part of migration to SLF4J

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected long` | `queryExecutionTimeLoggingThreshold`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Slf4jJdbcEventLogger(RuntimeProperties runtimeProperties)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `isLoggable()` Returns true if current thread default log level is high enough to generate output.
    `void` | `log(String message)` Logs an arbitrary message.
    `void` | `logBeginTransaction(String transactionLabel)`
    `void` | `logCommitTransaction(String transactionLabel)`
    `void` | `logConnect(String dataSource)` Deprecated.
    `void` | `logConnect(String url, String userName, String password)` Deprecated.
    `void` | `logConnectFailure(Throwable th)` Deprecated.
    `void` | `logConnectSuccess()` Deprecated.
    `void` | `logGeneratedKey(DbAttribute attribute, Object value)`
    `void` | `logPoolCreated(DataSourceInfo dsi)` Deprecated.
    `void` | `logQuery(String queryStr, List<?> params)` Deprecated. since 4.0 use `#logQuery(String, ParameterBinding[], long)`.
    `void` | `logQuery(String queryStr, List<DbAttribute> attrs, List<?> params, long time)` Deprecated.
    `void` | `logQuery(String sql, ParameterBinding[] bindings)`
    `void` | `logQueryError(Throwable th)`
    `void` | `logQueryParameters(String label, List<DbAttribute> attrs, List<Object> parameters, boolean isInserting)` Deprecated. since 4.0
    `void` | `logQueryParameters(String label, ParameterBinding[] bindings)`
    `void` | `logRollbackTransaction(String transactionLabel)`
    `void` | `logSelectCount(int count, long time)`
    `void` | `logSelectCount(int count, long time, String sql)`
    `void` | `logUpdateCount(int count)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### queryExecutionTimeLoggingThreshold

          protected long queryExecutionTimeLoggingThreshold

  - ### Constructor Detail

    - #### Slf4jJdbcEventLogger

          public Slf4jJdbcEventLogger(RuntimeProperties runtimeProperties)

  - ### Method Detail

    - #### log

          public void log(String message)

      Description copied from interface: `JdbcEventLogger`
      Logs an arbitrary message.
      Specified by:
        `log` in interface `JdbcEventLogger`

    - #### logConnect

          @Deprecated
          public void logConnect(String dataSource)

      Deprecated.
      Description copied from interface: `JdbcEventLogger`
      Logs database connection event using container data source.
      Specified by:
        `logConnect` in interface `JdbcEventLogger`

    - #### logConnect

          @Deprecated
          public void logConnect(String url,
                                              String userName,
                                              String password)

      Deprecated.
      Specified by:
        `logConnect` in interface `JdbcEventLogger`

    - #### logPoolCreated

          @Deprecated
          public void logPoolCreated(DataSourceInfo dsi)

      Deprecated.
      Specified by:
        `logPoolCreated` in interface `JdbcEventLogger`

    - #### logConnectSuccess

          @Deprecated
          public void logConnectSuccess()

      Deprecated.
      Specified by:
        `logConnectSuccess` in interface `JdbcEventLogger`

    - #### logConnectFailure

          @Deprecated
          public void logConnectFailure(Throwable th)

      Deprecated.
      Specified by:
        `logConnectFailure` in interface `JdbcEventLogger`

    - #### logGeneratedKey

          public void logGeneratedKey(DbAttribute attribute,
                                      Object value)

      Specified by:
        `logGeneratedKey` in interface `JdbcEventLogger`

    - #### logQuery

          @Deprecated
          public void logQuery(String queryStr,
                                            List<?> params)

      Deprecated. since 4.0 use `#logQuery(String, ParameterBinding[], long)`.
      Specified by:
        `logQuery` in interface `JdbcEventLogger`

    - #### logQuery

          public void logQuery(String sql,
                               ParameterBinding[] bindings)

      Specified by:
        `logQuery` in interface `JdbcEventLogger`

    - #### logQuery

          @Deprecated
          public void logQuery(String queryStr,
                                            List<DbAttribute> attrs,
                                            List<?> params,
                                            long time)

      Deprecated.
      Specified by:
        `logQuery` in interface `JdbcEventLogger`

    - #### logQueryParameters

          @Deprecated
          public void logQueryParameters(String label,
                                                      List<DbAttribute> attrs,
                                                      List<Object> parameters,
                                                      boolean isInserting)

      Deprecated. since 4.0
      Specified by:
        `logQueryParameters` in interface `JdbcEventLogger`

    - #### logQueryParameters

          public void logQueryParameters(String label,
                                         ParameterBinding[] bindings)

      Specified by:
        `logQueryParameters` in interface `JdbcEventLogger`

    - #### logSelectCount

          public void logSelectCount(int count,
                                     long time)

      Specified by:
        `logSelectCount` in interface `JdbcEventLogger`

    - #### logSelectCount

          public void logSelectCount(int count,
                                     long time,
                                     String sql)

      Specified by:
        `logSelectCount` in interface `JdbcEventLogger`
      Parameters:
        `count` - of selected rows
        `time` - (milliseconds) time query took to run
        `sql` - SQL that was executed, printed when time exceeds timeThreshold

    - #### logUpdateCount

          public void logUpdateCount(int count)

      Specified by:
        `logUpdateCount` in interface `JdbcEventLogger`

    - #### logBeginTransaction

          public void logBeginTransaction(String transactionLabel)

      Specified by:
        `logBeginTransaction` in interface `JdbcEventLogger`

    - #### logCommitTransaction

          public void logCommitTransaction(String transactionLabel)

      Specified by:
        `logCommitTransaction` in interface `JdbcEventLogger`

    - #### logRollbackTransaction

          public void logRollbackTransaction(String transactionLabel)

      Specified by:
        `logRollbackTransaction` in interface `JdbcEventLogger`

    - #### logQueryError

          public void logQueryError(Throwable th)

      Specified by:
        `logQueryError` in interface `JdbcEventLogger`

    - #### isLoggable

          public boolean isLoggable()

      Description copied from interface: `JdbcEventLogger`
      Returns true if current thread default log level is high enough to generate output.
      Specified by:
        `isLoggable` in interface `JdbcEventLogger`

Copyright © 2001–2018 Apache Cayenne. All rights reserved.