Documentation Home
MySQL 5.7 Reference Manual
Related Documentation Download this Manual
PDF (US Ltr) - 37.9Mb
PDF (A4) - 37.9Mb
PDF (RPM) - 37.3Mb
HTML Download (TGZ) - 10.3Mb
HTML Download (Zip) - 10.3Mb
HTML Download (RPM) - 8.9Mb
Man Pages (TGZ) - 216.8Kb
Man Pages (Zip) - 329.5Kb
Info (Gzip) - 3.4Mb
Info (Zip) - 3.4Mb
Excerpts from this Manual

MySQL 5.7 Reference Manual  /  MySQL Shell User Guide  /  MySQL Shell Application Log

18.5 MySQL Shell Application Log

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.

MySQL Shell Log File Location

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.

Configuring Logging

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 NumberLog Level NameMeaning

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

User Comments
Sign Up Login You must be logged in to post a comment.