Package org.hibernate.engine.jdbc.spi
Class SqlStatementLogger
- java.lang.Object
-
- org.hibernate.engine.jdbc.spi.SqlStatementLogger
-
public class SqlStatementLogger extends java.lang.ObjectCentralize logging for SQL statements.
-
-
Constructor Summary
Constructors Constructor Description SqlStatementLogger()Constructs a new SqlStatementLogger instance.SqlStatementLogger(boolean logToStdout, boolean format)Constructs a new SqlStatementLogger instance.SqlStatementLogger(boolean logToStdout, boolean format, boolean highlight)Constructs a new SqlStatementLogger instance.SqlStatementLogger(boolean logToStdout, boolean format, boolean highlight, long logSlowQuery)Constructs a new SqlStatementLogger instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description longgetLogSlowQuery()booleanisFormat()booleanisLogToStdout()Are we currently logging to stdout?voidlogSlowQuery(java.lang.String sql, long startTimeNanos)Log a slow SQL queryvoidlogSlowQuery(java.sql.Statement statement, long startTimeNanos)Log a slow SQL queryvoidlogStatement(java.lang.String statement)Log a SQL statement string.voidlogStatement(java.lang.String statement, org.hibernate.engine.jdbc.internal.Formatter formatter)Log a SQL statement string using the specified formattervoidsetFormat(boolean format)Deprecated.Will likely be removed: Should either become immutable or threadsafe.voidsetLogToStdout(boolean logToStdout)Deprecated.Will likely be removed: Should either become immutable or threadsafe.
-
-
-
Constructor Detail
-
SqlStatementLogger
public SqlStatementLogger()
Constructs a new SqlStatementLogger instance.
-
SqlStatementLogger
public SqlStatementLogger(boolean logToStdout, boolean format)Constructs a new SqlStatementLogger instance.- Parameters:
logToStdout- Should we log to STDOUT in addition to our internal logger.format- Should we format the statements in the console and log
-
SqlStatementLogger
public SqlStatementLogger(boolean logToStdout, boolean format, boolean highlight)Constructs a new SqlStatementLogger instance.- Parameters:
logToStdout- Should we log to STDOUT in addition to our internal logger.format- Should we format the statements in the console and loghighlight- Should we highlight the statements in the console
-
SqlStatementLogger
public SqlStatementLogger(boolean logToStdout, boolean format, boolean highlight, long logSlowQuery)Constructs a new SqlStatementLogger instance.- Parameters:
logToStdout- Should we log to STDOUT in addition to our internal logger.format- Should we format the statements in the console and loghighlight- Should we highlight the statements in the consolelogSlowQuery- Should we logs query which executed slower than specified milliseconds. 0 - disabled.
-
-
Method Detail
-
isLogToStdout
public boolean isLogToStdout()
Are we currently logging to stdout?- Returns:
- True if we are currently logging to stdout; false otherwise.
-
setLogToStdout
@Deprecated public void setLogToStdout(boolean logToStdout)
Deprecated.Will likely be removed: Should either become immutable or threadsafe.Enable (true) or disable (false) logging to stdout.- Parameters:
logToStdout- True to enable logging to stdout; false to disable.
-
isFormat
public boolean isFormat()
-
setFormat
@Deprecated public void setFormat(boolean format)
Deprecated.Will likely be removed: Should either become immutable or threadsafe.
-
getLogSlowQuery
public long getLogSlowQuery()
-
logStatement
public void logStatement(java.lang.String statement)
Log a SQL statement string.- Parameters:
statement- The SQL statement.
-
logStatement
public void logStatement(java.lang.String statement, org.hibernate.engine.jdbc.internal.Formatter formatter)Log a SQL statement string using the specified formatter- Parameters:
statement- The SQL statement.formatter- The formatter to use.
-
logSlowQuery
public void logSlowQuery(java.sql.Statement statement, long startTimeNanos)Log a slow SQL query- Parameters:
statement- SQL statement.startTimeNanos- Start time in nanoseconds.
-
logSlowQuery
public void logSlowQuery(java.lang.String sql, long startTimeNanos)Log a slow SQL query- Parameters:
sql- The SQL query.startTimeNanos- Start time in nanoseconds.
-
-