The location of the MySQL Shell application log file is the user configuration path and the file is namedmysqlsh.log. By default, MySQL Shell sends logging information at logging level 5 (error, warning, and informational messages) to this file.
Log messages are timestamped in UTC format.
To change the level of logging information that is sent, or to disable logging to the application log file, choose one of these options:
Use the
--log-levelcommand-line option when starting MySQL Shell.Use the MySQL Shell
\optioncommand to set thelogLevelMySQL Shell configuration option. For instructions to use this command, seeSection 13.4, “Configuring MySQL Shell Options”.Use the
shell.optionsobject to set thelogLevelMySQL Shell configuration option. For instructions to use this configuration interface, seeSection 13.4, “Configuring MySQL Shell Options”.
The available logging levels are as listed inTable 12.1, “Logging levels in MySQL Shell”. If you specify a logging level of 1 ornone for the option, logging to the application log file is disabled. All other values leave logging enabled and set the level of detail in the log file. The option requires a value.
With the--log-level command-line option, you can specify the logging level using its text name or the numeric equivalent, so the following examples have the same effect:
$> mysqlsh --log-level=4$> mysqlsh --log-level=warning With thelogLevel MySQL Shell configuration option, you can only specify a numeric logging level.
If you prepend the logging level with @ (at sign), log entries are output to an additional viewable location as well as being written to the MySQL Shell log file. The following examples have the same effect:
$> mysqlsh --log-level=@8$> mysqlsh --log-level=@debug3 On Unix-based systems, the log entries are output tostderr in the output format that is currently set for MySQL Shell. This is the value of theresultFormat MySQL Shell configuration option, unless JSON wrapping has been activated by starting MySQL Shell with the--json command line option.
On Windows systems, the log entries are printed using theOutputDebugString() function, whose output can be viewed in an application debugger, the system debugger, or a capture tool for debug output.
The MySQL Shell log file format is plain text and entries contain a timestamp and description of the problem, along with the logging level from the above list. For example:
2016-04-05 22:23:01: Error: Default Domain: (shell):1:8: MySQLError: You have an errorin your SQL syntax; check the manual that corresponds to your MySQL server version forthe right syntax to use near '' at line 1 (1064) in session.runSql("select * from tlimit").execute().all(); On Windows, the default path to the application log file is%APPDATA%\MySQL\mysqlsh\mysqlsh.log. To find the location of%APPDATA% on your system, echo it from the command line. For example:
C:>echo %APPDATA%C:\Users\exampleuser\AppData\Roaming On Windows, the path is the%APPDATA% folder specific to the user, withMySQL\mysqlsh added. Using the above example the path would beC:\Users\exampleuser\AppData\Roaming\MySQL\mysqlsh\mysqlsh.log.
If you want the application log file to be stored in a different location, you can override the default user configuration path by defining the environment variableMYSQLSH_USER_CONFIG_HOME. The value of this variable replaces%AppData%\MySQL\mysqlsh\ on Windows.
From MySQL Shell 8.0.27, you can also use the--log-file option to override the user configuration path when you runmysqlsh from the command line. The--log-file option applies to the individual MySQL Shell instance, meaning that different instances can write to different locations.
For a machine running Unix, the default path to the application log file is~/.mysqlsh/mysqlsh.log where“~” represents the user's home directory. The environment variableHOME also represents the user's home directory. Appending.mysqlsh to the user's home directory determines the default path to the log.
If you want the application log file to be stored in a different location, you can override the default user configuration path by defining the environment variableMYSQLSH_USER_CONFIG_HOME. The value of this variable replaces~/.mysqlsh/ on Unix.
From MySQL Shell 8.0.27, you can also use the--log-file option to override the user configuration path when you runmysqlsh from the command line. The--log-file option applies to the individual MySQL Shell instance, meaning that different instances can write to different locations.