MySQL Shell 9.1  /  MySQL Shell Logging and Debug

Chapter 12 MySQL Shell Logging and Debug

You can use MySQL Shell's logging feature to verify the state of MySQL Shell while it is running and to troubleshoot any issues.

By default, MySQL Shell sends logging information at logging level 5 (error, warning, and informational messages) to an application log file. You can also configure MySQL Shell to send the information to an optional additional viewable location, and to the console as verbose output.

You can control the level of detail to be sent to each destination. For the application log and additional viewable location, you can specify any of the available levels as the maximum level of detail. For verbose output, you can specify a setting that maps to a maximum level of detail. The following levels of detail are available:

Table 12.1 Logging levels in MySQL Shell

Logging Level - Numeric Logging Level - Text Meaning Verbose Setting

1

none

No logging

0

2

internal

Internal Error

1

3

error

Error

1

4

warning

Warning

1

5

info

Informational

1

6

debug

Debug

2

7

debug2

Debug2

3

8

debug3

Debug3

4

You can choose to send SQL statements that you issue interactively in MySQL Shell's SQL mode to the operating system’s system logging facility (syslog on Unix, or the Windows Event Log). SQL statements that would be excluded from the MySQL Shell code history are not sent to the system logging facility.

By default, MySQL Shell does not log or output SQL statements that are executed by MySQL Shell itself in the course of AdminAPI operations. You can activate logging for these statements if you want to observe the progress of these operations in terms of SQL execution, in addition to the messages returned during the operations. The statements are written to the MySQL Shell application log file as informational messages provided that the logging level is set to 5 or above. They are also sent to the console as verbose output provided that the verbose setting is 1 or above.

By default, MySQL Shell sends all logging for a program to the same application log file, and all output for a program to the same destination. The function shell.create_context can be used in MySQL Shell's Python mode to support multithreading by Python programs. The function is used inside a new Python thread to create a scope which isolates logging, interrupts, and delegates. The context wrapper handles and isolates output printed to stdout and stderr and diagnostic output, and also user input, with separate handling for passwords. You can also create an individual application log file specific to the thread.

For instructions to configure the application log and the optional additional destination, which is stderr on Unix-based systems or the OutputDebugString() function on Windows systems, see Section 12.1, “Application Log”.

For instructions to send logging information to the console as verbose output, see Section 12.2, “Verbose Output”.

For instructions to send interactive SQL statements to the system logging facility, see Section 12.3, “System Logging for User SQL Statements”.

For instructions to activate logging for SQL statements that are executed by AdminAPI operations, see Section 12.4, “MySQL Shell SQL Logging”.