General Query Log
suggest changeThe general query log lists client connects, disconnects, and queries. It is useful for debugging and expensive on a busy server, so leave it off except while you are diagnosing a problem.
An example view of a General Query Log is seen below:
To determine if the General Log is currently being captured:
SELECT @@general_log; -- 1 = Capture is active; 0 = It is not.
To determine the filename of the capture file:
SELECT @@general_log_file; -- Full path to capture file
If the full path is not shown, the file is in the data directory.
Windows example:
+----------------------------------------------------------+
| @@general_log_file |
+----------------------------------------------------------+
| C:\ProgramData\MySQL\MySQL Server 5.7\Data\GuySmiley.log |
+----------------------------------------------------------+
Linux:
+-----------------------------------+
| @@general_log_file |
+-----------------------------------+
| /var/lib/mysql/ip-ww-xx-yy-zz.log |
+-----------------------------------+
When you change the global general_log_file, a relative name is stored under the data directory. The variable may then show only that relative name.
In the case of no entry for general_log_file in the configuration file, it will default to @@hostname.log in the datadir.
Turn capture off, move the file to a backup directory with a name that shows the start and end time, set a new file name, and turn capture on only while debugging. If the old file was copied rather than moved, delete the copy still in the data directory. The sequence below does the server-side steps.
A typical filesystem filename for a backed-up log might be:
/LogBackup/GeneralLog_20160802_1520_to_20160802_1815.log
where the date and time in the filename are the capture range.
For Windows note the following sequence with setting changes.
SELECT @@general_log; -- 0. Not being captured
SELECT @@general_log_file; -- C:\ProgramData\MySQL\MySQL Server 5.7\Data\GuySmiley.log
SELECT @@datadir; -- C:\ProgramData\MySQL\MySQL Server 5.7\Data\
SET GLOBAL general_log_file='GeneralLogBegin_20160803_1420.log'; -- datetime clue
SET GLOBAL general_log=1; -- Turns on actual log capture. File is created under `datadir`
SET GLOBAL general_log=0; -- Turn logging off
Linux is similar. These would represent dynamic changes. Any restart of the server would pick up configuration file settings.
As for the configuration file, consider the following relevant variable settings:
[mysqld]
general_log_file = /path/to/currentquery.log
general_log = 1
In addition, the variable log_output can be configured for TABLE output, not just FILE. For that, please see Destinations.
Please see the MySQL Manual Page The General Query Log.