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 newSqlStatementLogger
instance.SqlStatementLogger
(boolean logToStdout, boolean format) Constructs a newSqlStatementLogger
instance.SqlStatementLogger
(boolean logToStdout, boolean format, boolean highlight) Constructs a newSqlStatementLogger
instance.SqlStatementLogger
(boolean logToStdout, boolean format, boolean highlight, long logSlowQuery) Constructs a newSqlStatementLogger
instance. -
Method Summary
Modifier and TypeMethodDescriptionlong
boolean
isFormat()
boolean
Are we currently logging to stdout?void
logSlowQuery
(String sql, long startTimeNanos, JdbcSessionContext context) Log a slow SQL queryvoid
logStatement
(String statement) Log a SQL statement string.void
logStatement
(String statement, Formatter formatter) Log a SQL statement string using the specified formatter
-
Constructor Details
-
SqlStatementLogger
public SqlStatementLogger()Constructs a newSqlStatementLogger
instance. -
SqlStatementLogger
public SqlStatementLogger(boolean logToStdout, boolean format) Constructs a newSqlStatementLogger
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 newSqlStatementLogger
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 newSqlStatementLogger
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 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.
-