Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.cayenne.access
Class QueryLogger

    java.lang.Object
      org.apache.cayenne.access.QueryLogger

    public class QueryLogger

extends Object

QueryLogger is intended to log special events that happen whenever Cayenne interacts with a database. This includes execution of generated SQL statements, result counts, connection events, etc. Normally QueryLogger methods are not invoked directly by the . Rather it is a single logging point used by the framework.

Internally QueryLogger uses commons-logging at the "info" level.

Field Summary
`static int` | `TRIM_VALUES_THRESHOLD`

Constructor Summary
`QueryLogger()`

Method Summary
`static boolean` | `isLoggable()` Returns true if current thread default log level is high enough for QueryLogger to generate output.
`static void` | `log(String message)`
`static void` | `logBeginTransaction(String transactionLabel)`
`static void` | `logCommitTransaction(String transactionLabel)`
`static void` | `logConnect(String dataSource)` Logs database connection event using container data source.
`static void` | `logConnect(String url, String userName, String password)`
`static void` | `logConnectFailure(Throwable th)`
`static void` | `logConnectSuccess()`
`static void` | `logGeneratedKey(DbAttribute attribute, Object value)`
`static void` | `logPoolCreated(DataSourceInfo dsi)` Logs database connection event.
`static void` | `logQuery(String queryStr, List<?> params)`
`static void` | `logQuery(String queryStr, List<DbAttribute> attrs, List<?> params, long time)` Log query content using Log4J Category with "INFO" priority.
`static void` | `logQueryError(Throwable th)`
`static void` | `logQueryParameters(String label, List<DbAttribute> attrs, List<Object> parameters, boolean isInserting)`
`static void` | `logQueryStart(int count)`
`static void` | `logRollbackTransaction(String transactionLabel)`
`static void` | `logSelectCount(int count)`
`static void` | `logSelectCount(int count, long time)`
`static void` | `logUpdateCount(int count)`
`static void` | `sqlLiteralForObject(StringBuffer buffer, Object object)` Appends SQL literal for the specified object to the buffer.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### TRIM_VALUES_THRESHOLD

    public static final int TRIM_VALUES_THRESHOLD

See Also:
  Constant Field Values

Constructor Detail

### QueryLogger

    public QueryLogger()

Method Detail

### sqlLiteralForObject

    public static void sqlLiteralForObject(StringBuffer buffer,
                                           Object object)

  Appends SQL literal for the specified object to the buffer. This is a utility method and is not intended to build SQL queries, rather this is used in logging routines. In particular it will trim large values to avoid flooding the logs.

  Parameters:
    `buffer` - buffer to append value
    `object` - object to be transformed to SQL literal.

### log

    public static void log(String message)

  Since:
    1.2 logs an arbitrary message using logging level setup for QueryLogger.

### logConnect

    public static void logConnect(String dataSource)

  Logs database connection event using container data source.

  Since:
    1.2

### logConnect

    public static void logConnect(String url,
                                  String userName,
                                  String password)

  Since:
    1.2

### logPoolCreated

    public static void logPoolCreated(DataSourceInfo dsi)

  Logs database connection event.

  Since:
    1.2

### logConnectSuccess

    public static void logConnectSuccess()

  Since:
    1.2

### logConnectFailure

    public static void logConnectFailure(Throwable th)

  Since:
    1.2

### logGeneratedKey

    public static void logGeneratedKey(DbAttribute attribute,
                                       Object value)

  Since:
    3.0

### logQuery

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

  Since:
    1.2

### logQuery

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

  Log query content using Log4J Category with "INFO" priority.

  Parameters:
    `queryStr` - Query SQL string
    `attrs` - optional list of DbAttribute (can be null)
    `params` - optional list of query parameters that are used when executing query in prepared statement.
  Since:
    1.2

### logQueryParameters

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

  Since:
    1.2

### logSelectCount

    public static void logSelectCount(int count)

  Since:
    1.2

### logSelectCount

    public static void logSelectCount(int count,
                                      long time)

  Since:
    1.2

### logUpdateCount

    public static void logUpdateCount(int count)

  Since:
    1.2

### logBeginTransaction

    public static void logBeginTransaction(String transactionLabel)

  Since:
    1.2

### logCommitTransaction

    public static void logCommitTransaction(String transactionLabel)

  Since:
    1.2

### logRollbackTransaction

    public static void logRollbackTransaction(String transactionLabel)

  Since:
    1.2

### logQueryError

    public static void logQueryError(Throwable th)

  Since:
    1.2

### logQueryStart

    public static void logQueryStart(int count)

  Since:
    1.2

### isLoggable

    public static boolean isLoggable()

  Returns true if current thread default log level is high enough for QueryLogger to generate output.

  Since:
    1.2

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2001-2009 Apache Cayenne. All Rights Reserved.