This section explains the logging provided by MySQL Shell, where to find logs and how to configure the level of logging.
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 log format is plain text and entries contain a timestamp and description of the problem. 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
limit").execute().all();
The amount of information to add to the log can be configured using
--log-level. See
Configuring Logging.
The location of the log file is the user configuration path and
the file is named mysqlsh.log.
Log File 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%
C:\Users\exampleuser\AppData\Roaming
On Windows, the path is determined by the result of gathering the
%APPDATA% folder specific to that user, and
then appending MySQL\mysqlsh. Using the above
example results in
C:\Users\exampleuser\AppData\Roaming\MySQL\mysqlsh\mysqlsh.log.
Log File on Unix-based Systems
For a machine running Unix, the default path is
~/.mysqlsh/mysqlsh.log where “~”
represents your home directory. The environment variable
HOME also represents the home directory.
Appending .mysqlsh to the this home directory
determines the default path to the logs. For example:
shell>echo $HOME
/home/exampleuser
Therefore the location of the MySQL Shell file on this system is
/home/exampleuser/.mysqlsh/mysqlsh.log.
These paths can be overridden on all platforms by defining the
environment variable MYSQL_USER_CONFIG_PATH.
The value of this variable replaces %APPDATA%
in Windows or $HOME in Unix.
By default, logging is disabled in MySQL Shell. To enable
logging use the --log-level
command option when starting MySQL Shell. The value assigned to
--log-level controls the level of
detail in the log. The level of logging can be defined using
either numeric levels from 1 to 8, or equivalent named levels as
shown in the following table.
| Log Level Number | Log Level Name | Meaning |
|---|---|---|
1 | none | No logging, the default |
2 | internal | Internal Error |
3 | error | Errors are logged |
4 | warning | Warnings are logged |
5 | info | Information is logged |
6 | debug | Debug information is logged |
7 | debug2 | Debug with more information is logged |
8 | debug3 | Debug with full information is logged |
The numeric and named levels are equivalent. For example there is no difference in logging when starting MySQL Shell in either of these ways:
shell>mysqlsh --log-level=4
shell>mysqlsh --log-level=warning