Overview | Package | Class | 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 java.lang.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 user. Rather it is a single logging point used by the framework.

Internally QueryLogger uses Log4J. See a chapter on logging in Cayenne User Guide on how to setup Log4J.

Author:
  Andrus Adamchik

Field Summary
`static org.apache.log4j.Level` | `DEFAULT_LOG_LEVEL` Deprecated. unused since 1.2
`static int` | `TRIM_VALUES_THRESHOLD`

Constructor Summary
`QueryLogger()`

Method Summary
`protected static void` | `appendFormattedByte(java.lang.StringBuffer buffer, byte byteValue)` Deprecated. since 1.2 use a namesake method from IDUtil.
`static org.apache.log4j.Level` | `getLoggingLevel()` Returns current logging level.
`static boolean` | `isLoggable()` Returns true if current thread default log level is high enough for QueryLogger to generate output.
`static boolean` | `isLoggable(org.apache.log4j.Level logLevel)` Deprecated. since 1.2
`static void` | `log(java.lang.String message)`
`static void` | `logBeginTransaction(org.apache.log4j.Level logLevel, java.lang.String transactionLabel)` Deprecated. since 1.2
`static void` | `logBeginTransaction(java.lang.String transactionLabel)`
`static void` | `logCommitTransaction(org.apache.log4j.Level logLevel, java.lang.String transactionLabel)` Deprecated. since 1.2
`static void` | `logCommitTransaction(java.lang.String transactionLabel)`
`static void` | `logConnect(org.apache.log4j.Level logLevel, java.lang.String dataSource)` Deprecated. since 1.2
`static void` | `logConnect(org.apache.log4j.Level logLevel, java.lang.String url, java.lang.String userName, java.lang.String password)` Deprecated. since 1.2
`static void` | `logConnect(java.lang.String dataSource)` Logs database connection event using container data source.
`static void` | `logConnect(java.lang.String url, java.lang.String userName, java.lang.String password)`
`static void` | `logConnectFailure(org.apache.log4j.Level logLevel, java.lang.Throwable th)` Deprecated. since 1.2
`static void` | `logConnectFailure(java.lang.Throwable th)`
`static void` | `logConnectSuccess()`
`static void` | `logConnectSuccess(org.apache.log4j.Level logLevel)` Deprecated. since 1.2
`static void` | `logPoolCreated(DataSourceInfo dsi)` Logs database connection event.
`static void` | `logPoolCreated(org.apache.log4j.Level logLevel, DataSourceInfo dsi)` Deprecated. since 1.2
`static void` | `logQuery(org.apache.log4j.Level logLevel, java.lang.String queryStr, java.util.List params)` Deprecated. since 1.2
`static void` | `logQuery(org.apache.log4j.Level logLevel, java.lang.String queryStr, java.util.List params, long time)` Deprecated. since 1.2
`static void` | `logQuery(java.lang.String queryStr, java.util.List params)`
`static void` | `logQuery(java.lang.String queryStr, java.util.List params, long time)` Log query content using Log4J Category with "INFO" priority.
`static void` | `logQueryError(org.apache.log4j.Level logLevel, java.lang.Throwable th)` Deprecated. since 1.2
`static void` | `logQueryError(java.lang.Throwable th)`
`static void` | `logQueryParameters(org.apache.log4j.Level logLevel, java.lang.String label, java.util.List parameters)` Deprecated. since 1.2
`static void` | `logQueryParameters(java.lang.String label, java.util.List parameters)`
`static void` | `logQueryStart(int count)`
`static void` | `logQueryStart(org.apache.log4j.Level logLevel, int count)` Deprecated. since 1.2
`static void` | `logRollbackTransaction(org.apache.log4j.Level logLevel, java.lang.String transactionLabel)` Deprecated. since 1.2
`static void` | `logRollbackTransaction(java.lang.String transactionLabel)`
`static void` | `logSelectCount(int count)`
`static void` | `logSelectCount(int count, long time)`
`static void` | `logSelectCount(org.apache.log4j.Level logLevel, int count)` Deprecated. since 1.2
`static void` | `logSelectCount(org.apache.log4j.Level logLevel, int count, long time)` Deprecated. since 1.2
`static void` | `logUpdateCount(int count)`
`static void` | `logUpdateCount(org.apache.log4j.Level logLevel, int count)` Deprecated. since 1.2
`static void` | `setLoggingLevel(org.apache.log4j.Level level)` Sets logging level for the current thread.
`static void` | `sqlLiteralForObject(java.lang.StringBuffer buf, java.lang.Object anObject)` Utility method that 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

### DEFAULT_LOG_LEVEL

    public static final org.apache.log4j.Level DEFAULT_LOG_LEVEL

  Deprecated. unused since 1.2

### 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(java.lang.StringBuffer buf,
                                           java.lang.Object anObject)

  Utility method that appends SQL literal for the specified object to the buffer.

  Note: this method is not intended to build SQL queries, rather this is used in logging routines only. In particular it will trim large values to avoid flooding the logs.

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

### appendFormattedByte

    protected static void appendFormattedByte(java.lang.StringBuffer buffer,
                                              byte byteValue)

  Deprecated. since 1.2 use a namesake method from IDUtil.

  Prints a byte value to a StringBuffer as a double digit hex value.

### getLoggingLevel

    public static org.apache.log4j.Level getLoggingLevel()

  Returns current logging level.

### setLoggingLevel

    public static void setLoggingLevel(org.apache.log4j.Level level)

  Sets logging level for the current thread.

### log

    public static void log(java.lang.String message)

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

### logConnect

    public static void logConnect(java.lang.String dataSource)

  Logs database connection event using container data source.

  Since:
    1.2

### logConnect

    public static void logConnect(java.lang.String url,
                                  java.lang.String userName,
                                  java.lang.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(java.lang.Throwable th)

  Since:
    1.2

### logQuery

    public static void logQuery(java.lang.String queryStr,
                                java.util.List params)

  Since:
    1.2

### logQuery

    public static void logQuery(java.lang.String queryStr,
                                java.util.List params,
                                long time)

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

  Parameters:
    `queryStr` - Query SQL string
    `params` - optional list of query parameters that are used when executing query in prepared statement.
  Since:
    1.2

### logQueryParameters

    public static void logQueryParameters(java.lang.String label,
                                          java.util.List parameters)

  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(java.lang.String transactionLabel)

  Since:
    1.2

### logCommitTransaction

    public static void logCommitTransaction(java.lang.String transactionLabel)

  Since:
    1.2

### logRollbackTransaction

    public static void logRollbackTransaction(java.lang.String transactionLabel)

  Since:
    1.2

### logQueryError

    public static void logQueryError(java.lang.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

### logConnect

    public static void logConnect(org.apache.log4j.Level logLevel,
                                  java.lang.String dataSource)

  Deprecated. since 1.2

  Logs database connection event using container data source.

### logConnect

    public static void logConnect(org.apache.log4j.Level logLevel,
                                  java.lang.String url,
                                  java.lang.String userName,
                                  java.lang.String password)

  Deprecated. since 1.2

### logPoolCreated

    public static void logPoolCreated(org.apache.log4j.Level logLevel,
                                      DataSourceInfo dsi)

  Deprecated. since 1.2

  Logs database connection event.

### logConnectSuccess

    public static void logConnectSuccess(org.apache.log4j.Level logLevel)

  Deprecated. since 1.2

### logConnectFailure

    public static void logConnectFailure(org.apache.log4j.Level logLevel,
                                         java.lang.Throwable th)

  Deprecated. since 1.2

### logQuery

    public static void logQuery(org.apache.log4j.Level logLevel,
                                java.lang.String queryStr,
                                java.util.List params)

  Deprecated. since 1.2

### logQuery

    public static void logQuery(org.apache.log4j.Level logLevel,
                                java.lang.String queryStr,
                                java.util.List params,
                                long time)

  Deprecated. since 1.2

### logQueryParameters

    public static void logQueryParameters(org.apache.log4j.Level logLevel,
                                          java.lang.String label,
                                          java.util.List parameters)

  Deprecated. since 1.2

### logSelectCount

    public static void logSelectCount(org.apache.log4j.Level logLevel,
                                      int count)

  Deprecated. since 1.2

### logSelectCount

    public static void logSelectCount(org.apache.log4j.Level logLevel,
                                      int count,
                                      long time)

  Deprecated. since 1.2

### logUpdateCount

    public static void logUpdateCount(org.apache.log4j.Level logLevel,
                                      int count)

  Deprecated. since 1.2

### logBeginTransaction

    public static void logBeginTransaction(org.apache.log4j.Level logLevel,
                                           java.lang.String transactionLabel)

  Deprecated. since 1.2

  Since:
    1.1

### logCommitTransaction

    public static void logCommitTransaction(org.apache.log4j.Level logLevel,
                                            java.lang.String transactionLabel)

  Deprecated. since 1.2

  Since:
    1.1

### logRollbackTransaction

    public static void logRollbackTransaction(org.apache.log4j.Level logLevel,
                                              java.lang.String transactionLabel)

  Deprecated. since 1.2

  Since:
    1.1

### logQueryError

    public static void logQueryError(org.apache.log4j.Level logLevel,
                                     java.lang.Throwable th)

  Deprecated. since 1.2

### logQueryStart

    public static void logQueryStart(org.apache.log4j.Level logLevel,
                                     int count)

  Deprecated. since 1.2

### isLoggable

    public static boolean isLoggable(org.apache.log4j.Level logLevel)

  Deprecated. since 1.2

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

Copyright © 2001-2006 Apache.org All Rights Reserved.