类 SqlStatementLogger


  • public class SqlStatementLogger
    extends Object
    Centralize logging for SQL statements.
    作者:
    Steve Ebersole
    • 构造器详细资料

      • SqlStatementLogger

        public SqlStatementLogger()
        Constructs a new SqlStatementLogger instance.
      • SqlStatementLogger

        public SqlStatementLogger​(boolean logToStdout,
                                  boolean format)
        Constructs a new SqlStatementLogger instance.
        参数:
        logToStdout - Should we log to STDOUT in addition to our internal logger.
        format - Should we format the statements prior to logging
      • SqlStatementLogger

        public SqlStatementLogger​(boolean logToStdout,
                                  boolean format,
                                  long logSlowQuery)
        Constructs a new SqlStatementLogger instance.
        参数:
        logToStdout - Should we log to STDOUT in addition to our internal logger.
        format - Should we format the statements prior to logging
        logSlowQuery - Should we logs query which executed slower than specified milliseconds. 0 - disabled.
    • 方法详细资料

      • isLogToStdout

        public boolean isLogToStdout()
        Are we currently logging to stdout?
        返回:
        True if we are currently logging to stdout; false otherwise.
      • setLogToStdout

        @Deprecated
        public void setLogToStdout​(boolean logToStdout)
        已过时。
        Will likely be removed: Should either become immutable or threadsafe.
        Enable (true) or disable (false) logging to stdout.
        参数:
        logToStdout - True to enable logging to stdout; false to disable.
      • isFormat

        public boolean isFormat()
      • setFormat

        @Deprecated
        public void setFormat​(boolean format)
        已过时。
        Will likely be removed: Should either become immutable or threadsafe.
      • getLogSlowQuery

        public long getLogSlowQuery()
      • logStatement

        public void logStatement​(String statement)
        Log a SQL statement string.
        参数:
        statement - The SQL statement.
      • logStatement

        public void logStatement​(String statement,
                                 Formatter formatter)
        Log a SQL statement string using the specified formatter
        参数:
        statement - The SQL statement.
        formatter - The formatter to use.
      • logSlowQuery

        public void logSlowQuery​(Statement statement,
                                 long startTime)
        Log a slow SQL query
        参数:
        statement - SQL statement.
        startTime - Start time in milliseconds.
      • logSlowQuery

        public void logSlowQuery​(String sql,
                                 long startTime)
        Log a slow SQL query
        参数:
        sql - The SQL query.
        startTime - Start time in milliseconds.