Package org.hibernate.engine.jdbc.spi
Class SqlStatementLogger
java.lang.Object
org.hibernate.engine.jdbc.spi.SqlStatementLogger
- All Implemented Interfaces:
Serializable,Service
Centralize logging for SQL statements.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a newSqlStatementLoggerinstance.SqlStatementLogger(boolean logToStdout, boolean format) Constructs a newSqlStatementLoggerinstance.SqlStatementLogger(boolean logToStdout, boolean format, boolean highlight) Constructs a newSqlStatementLoggerinstance.SqlStatementLogger(boolean logToStdout, boolean format, boolean highlight, long logSlowQuery) Constructs a newSqlStatementLoggerinstance. -
Method Summary
Modifier and TypeMethodDescriptionlongbooleanisFormat()booleanAre we currently logging to stdout?voidlogSlowQuery(String sql, long startTimeNanos, JdbcSessionContext context) Log a slow SQL queryvoidlogStatement(String statement) Log a SQL statement string.voidlogStatement(String statement, Formatter formatter) Log a SQL statement string using the specified formatter
-
Constructor Details
-
SqlStatementLogger
public SqlStatementLogger()Constructs a newSqlStatementLoggerinstance. -
SqlStatementLogger
public SqlStatementLogger(boolean logToStdout, boolean format) Constructs a newSqlStatementLoggerinstance.- 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 newSqlStatementLoggerinstance.- 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 newSqlStatementLoggerinstance.- 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 Details
-
isLogToStdout
public boolean isLogToStdout()Are we currently logging to stdout?- Returns:
- True if we are currently logging to stdout; false otherwise.
-
isFormat
public boolean isFormat() -
getLogSlowQuery
public long getLogSlowQuery() -
logStatement
Log a SQL statement string.- Parameters:
statement- The SQL statement.
-
logStatement
Log a SQL statement string using the specified formatter- Parameters:
statement- The SQL statement.formatter- The formatter to use.
-
logSlowQuery
Log a slow SQL query- Parameters:
sql- The SQL query.startTimeNanos- Start time in nanoseconds.
-