## Log Control at Server Startup 

The log_output  system variable specifies the destination for log output. Setting this variable does not in itself enable the logs; they must be enabled separately. 

•If log_output  is not specified at startup, the default logging destination is FILE . 

•If log_output  is specified at startup, its value is a list one or more comma-separated words chosen from TABLE  (log to tables), FILE  (log to files), or NONE  (do not log to tables or files). NONE , if present, takes precedence over any other specifiers. 

The general_log  system variable controls logging to the general query log for the selected log destinations. If specified at server startup, general_log  takes an optional argument of 1 or 0 to enable or disable the log. To specify a file name other than the default for file logging, set the general_log_file variable. Similarly, the slow_query_log  variable controls logging to the slow query log for the selected destinations and setting slow_query_log_file  specifies a file name for file logging. If either log is enabled, the server opens the corresponding log file and writes startup messages to it. However, further logging of queries to the file does not occur unless the FILE  log destination is selected. 

Examples: 

•To write general query log entries to the log table and the log file, use --log_output=TABLE,FILE  to select both log destinations and --general_log  to enable the general query log. 

•To write general and slow query log entries only to the log tables, use --log_output=TABLE  to select tables as the log destination and --general_log  and --slow_query_log  to enable both logs. 

•To write slow query log entries only to the log file, use --log_output=FILE  to select files as the log destination and --slow_query_log  to enable the slow query log. In this case, because the default log destination is FILE , you could omit the log_output  setting. 

## Log Control at Runtime 

The system variables associated with log tables and files enable runtime control over logging: 

•The log_output  variable indicates the current logging destination. It can be modified at runtime to change the destination. 

•The general_log  and slow_query_log  variables indicate whether the general query log and slow query log are enabled ( ON ) or disabled ( OFF ). You can set these variables at runtime to control whether the logs are enabled. 

•The general_log_file  and slow_query_log_file  variables indicate the names of the general query log and slow query log files. You can set these variables at server startup or at runtime to change the names of the log files. 

•To disable or enable general query logging for the current session, set the session sql_log_off variable to ON  or OFF . (This assumes that the general query log itself is enabled.) 

## Log Table Benefits and Characteristics 

The use of tables for log output offers the following benefits: 

•Log entries have a standard format. To display the current structure of the log tables, use these statements: 

SHOW CREATE TABLE mysql.general_log; SHOW CREATE TABLE mysql.slow_log; 

