Package org.hibernate.engine.jdbc.spi
Class SqlStatementLogger
- java.lang.Object
-
- org.hibernate.engine.jdbc.spi.SqlStatementLogger
-
- All Implemented Interfaces:
Serializable
,Service
public class SqlStatementLogger extends Object implements Service
Centralize logging for SQL statements.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description SqlStatementLogger()
Constructs 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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description long
getLogSlowQuery()
boolean
isFormat()
boolean
isLogToStdout()
Are we currently logging to stdout?void
logSlowQuery(String sql, long startTimeNanos, JdbcSessionContext context)
Log a slow SQL queryvoid
logSlowQuery(Statement statement, 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 Detail
-
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 Detail
-
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
public void logStatement(String statement)
Log a SQL statement string.- Parameters:
statement
- The SQL statement.
-
logStatement
public void logStatement(String statement, 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(Statement statement, long startTimeNanos, JdbcSessionContext context)
Log a slow SQL query- Parameters:
statement
- SQL statement.startTimeNanos
- Start time in nanoseconds.
-
logSlowQuery
public void logSlowQuery(String sql, long startTimeNanos, JdbcSessionContext context)
Log a slow SQL query- Parameters:
sql
- The SQL query.startTimeNanos
- Start time in nanoseconds.
-
-