MySQL Shell 8.4
You can log all SQL statements executed by MySQL Shell commands or utilities to the MySQL Shell log file.
logSql
replaces
dba.logSql
if dba.logSql
is disabled, logSql
takes precedence.
However, if dba.logSql
is enabled, it takes
precedence over logSql
, but only for log
messages in the dba.*
context.
The application log level must be set to at least INFO
(5)
, for these messages to be written to the
MySQL Shell log.
MySQL Shell SQL logging can be enabled, disabled, or altered in one of the following ways:
Command line:
--log-sql=
in your MySQL Shell startup command.
logOption
MySQL Shell configuration options:
shell.options['logSql']='
during your MySQL Shell session.
logOption
'
The following options are available:
No MySQL Shell SQL statements are logged.
(Default) only MySQL Shell failed SQL statements with are logged.
All MySQL Shell SQL statements are logged, except those
which match the ignore pattern defined in
logSql.ignorePattern
and
logSql.ignorePatternUnsafe
. See
Filtering SQL Logging for more
information.
All MySQL Shell SQL statements are logged, except those
which match the ignore pattern defined in the
logSql.ignorePatternUnsafe]
. See
Filtering SQL Logging for more
information.
All MySQL Shell SQL statements are logged, no filtering is performed.
The log is filtered using a colon-separated list of glob patterns. The following options are available:
logSql.ignorePattern
: This option defines
a colon-separated list of statement patterns to filter out.
Default value is *SELECT*:*SHOW*
.
logSql.ignorePatternUnsafe
: This option
defines a colon-separated list of statement patterns to
filter out. Default value is
*IDENTIFIED*:*PASSWORD*
.
For information on working with
shell.options
, see
Section 13.4, “Configuring MySQL Shell Options”.
The log messages use the following format:
Date&Time: LogLevel: LogContext: tid= : SQL:
Date and time of the log message.
The log level. For more information on log levels, seeTable 12.1, “Logging levels in MySQL Shell”.
All successful SQL statements and error messages for
unsuccessful statements are logged with
INFO
log level.
The origin of the log message. Can be one of the following values:
main: base MySQL Shell context.
sql: SQL mode context.
js: JavaScript mode context.
py: Python mode context.
object.method
: Global
object method context. For example,
Dba.createCluster
or
Cluster.status
.
The MySQL thread ID.
The logged SQL statement or error message.
The following example shows an SQL INFO message with a
Dba.deploySandboxInstance
context:
2022-06-17 15:06:00: Info: Dba.deploySandboxInstance: tid=9: SQL: SET SESSION `autocommit` = 1