This is MUCH more simply done this way:
cd to mysql folders:
mkfifo mysql-general.log
in my.cnf tell it:
[mysqld]
general-log-file = /path/to/mysql/dir/mysql-general.log
Then, configure your syslog/syslog-ng to read the FIFO pipe and do with it as it will..
In my case, I pipe it across net to a centralized server with only the error logs and slow query logs however.
In situations where you want to also keep local copy, just set it to output to table and file as described above.
The flags you need to activate the general log and the slow on in the MySQL Documentation
I would recommend using log-output=TABLE
It will save the logging of general log and slow log info to MySQL tables
mysql.general_log
mysql.slow_log
You should convert them to MyISAM. That way, you can index the tables by the timestamp and perform SELECT queries from them.
By default, these files use the CSV storage engine.
mysql> show create table mysql.general_log\G
*************************** 1. row ***************************
Table: general_log
Create Table: CREATE TABLE `general_log` (
`event_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`user_host` mediumtext NOT NULL,
`thread_id` int(11) NOT NULL,
`server_id` int(10) unsigned NOT NULL,
`command_type` varchar(64) NOT NULL,
`argument` mediumtext NOT NULL
) ENGINE=CSV DEFAULT CHARSET=utf8 COMMENT='General log'
1 row in set (0.09 sec)
mysql> show create table mysql.slow_log\G
*************************** 1. row ***************************
Table: slow_log
Create Table: CREATE TABLE `slow_log` (
`start_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`user_host` mediumtext NOT NULL,
`query_time` time NOT NULL,
`lock_time` time NOT NULL,
`rows_sent` int(11) NOT NULL,
`rows_examined` int(11) NOT NULL,
`db` varchar(512) NOT NULL,
`last_insert_id` int(11) NOT NULL,
`insert_id` int(11) NOT NULL,
`server_id` int(10) unsigned NOT NULL,
`sql_text` mediumtext NOT NULL
) ENGINE=CSV DEFAULT CHARSET=utf8 COMMENT='Slow log'
1 row in set (0.05 sec)
mysql>
Convert the general log and index it by event_time:
SET @old_log_state = @@global.general_log;
SET GLOBAL general_log = 'OFF';
ALTER TABLE mysql.general_log ENGINE = MyISAM;
ALTER TABLE mysql.general_log ADD INDEX (event_time);
SET GLOBAL general_log = @old_log_state;
Convert the slow log and index it by start_time:
SET @old_log_state = @@global.slow_query_log;
SET GLOBAL slow_query_log = 'OFF';
ALTER TABLE mysql.slow_log ENGINE = MyISAM;
ALTER TABLE mysql.slow_log ADD INDEX (start_time);
SET GLOBAL slow_query_log = @old_log_state;
Give it a Try !!!
Best Answer
Add this to my.ini
If you have a specfic place for the log, such as C:\mysql_general.log
It's one of those. I haven't done mysql in Windows in a while.
Then restart mysql
Give it a Try !!!
CAVEAT
Prior to MySQL 5.6, you can use log.
In MySQL 5.6, log is deprecated. Use general-log instead.
UPDATE 2011-12-09 22:18 EDT
If you do not have my.ini defined, then you must define one.
To keep things simple, just create my.ini in the folder where my-huge.ini, my-large.ini, my-medium.ini, and my-small.ini appear. Just open up notepad on my.ini in that folder.
Then add the lines I mentioned before:
or
UPDATE 2011-12-09 22:26 EDT
In the worst case, try putting my.ini in C:\