Documentation Home
MySQL Shell 8.0
Related Documentation Download this Manual
PDF (US Ltr) - 376.8Kb
PDF (A4) - 371.1Kb
HTML Download (TGZ) - 74.7Kb
HTML Download (Zip) - 86.5Kb

MySQL Shell 8.0  /  MySQL Shell Application Log  /  Application Log

8.1 Application Log

MySQL Shell can be configured to generate an application log file with information about issues of varying severity. You can use this information to verify the state of MySQL Shell while it is running.

The location of the log file is the user configuration path and the file is named mysqlsh.log.

By default, logging is disabled in MySQL Shell. To enable logging use the --log-level command-line option when starting MySQL Shell, or use either the \option command or the shell.options object to set the logLevel MySQL Shell configuration option. If the option is not set on the command line or in the configuration file, or if you specify a logging level of 1 or none, logging is disabled. All other values enable logging and set the level of detail in the log as follows:

Logging Level - Numeric Logging Level - Text Meaning



None, the default



Internal Error



















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:

shell> mysqlsh --log-level=4
shell> mysqlsh --log-level=warning

With the logLevel 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:

shell> mysqlsh --log-level=@8
shell> mysqlsh --log-level=@debug3

On Unix-based systems, the log entries are output to stderr in the output format that is currently set for MySQL Shell. This is the value of the resultFormat 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 the OutputDebugString() 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 error
in your SQL syntax; check the manual that corresponds to your MySQL server version for
the right syntax to use near '' at line 1 (1064) in session.sql("select * from t

The default user configuration path can be overridden on all platforms by defining the environment variable MYSQLSH_USER_CONFIG_HOME. The value of this variable replaces %AppData%\MySQL\mysqlsh\ on Windows or ~/.mysqlsh/ on Unix.

Log File Location on Windows

On Windows, the default path to the log file is %APPDATA%\MySQL\mysqlsh\mysqlsh.log

To find the location of %APPDATA% on your system, echo it from the comand-line. For example:

C:>echo %APPDATA%


On Windows, the path is the %APPDATA% folder specific to the user, with MySQL\mysqlsh added. Using the above example the path would be C:\Users\exampleuser\AppData\Roaming\MySQL\mysqlsh\mysqlsh.log .

Log File Location on Unix-based Systems

For a machine running Unix, the default path is ~/.mysqlsh/mysqlsh.log where ~ represents the user's home directory. The environment variable HOME also represents the user's home directory. Appending .mysqlsh to the user's home directory determines the default path to the logs.