[MDEV-30315] General Log: add timestamp to each line of the log Created: 2022-12-28  Updated: 2023-12-21  Resolved: 2023-12-21

Status: Closed
Project: MariaDB Server
Component/s: Configuration
Fix Version/s: N/A

Type: New Feature Priority: Major
Reporter: Yakov Kushnirsky Assignee: Unassigned
Resolution: Won't Fix Votes: 0
Labels: None

Attachments: JPEG File Logs_ts_MySQL_vs_MariaDB.JPG    
Issue Links:
Duplicate

 Description   

There is an enhancement request to configure General Log of MariaDB (when logging to a file) with ability to record a timestamp for every line of the Log.



 Comments   
Comment by Hari Hara Naveen S [ 2022-12-30 ]

Currently each line in the log file has YYMMDD HH:MM:SS time. Has this enhancement been implemented or does it request for an option to log UNIX timestamps?

Comment by Sergei Golubchik [ 2023-12-18 ]

YK, how do you think it should work? I'm looking at the general log and I see something like

/home/maria/sql/mariadbd, Version: 10.11.7-MariaDB-debug-log (Source distribution). started with:
Tcp port: 16000  Unix socket: /home/maria/mysql-test/var/tmp/mysqld.1.sock
Time		    Id Command	Argument
231218 19:39:44	     3 Connect	root@localhost on  using Socket
		     3 Query	SHOW SLAVE STATUS
		     3 Query	select count(*) from mysql.proc
		     4 Query	drop table if exists t1,t2,t3,t4,t11
		     4 Query	drop view if exists v1
		     4 Query	set optimizer_use_condition_selectivity=4
		     4 Query	CREATE TABLE t1 (
Period smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL,
Varor_period smallint(4) unsigned DEFAULT '0' NOT NULL
)
		     4 Query	INSERT INTO t1 VALUES (9410,9412)
		     4 Query	select period from t1
		     4 Query	select * from t1

There's

  • a line with the server version
  • a line with the port and socket
  • header line with column names
  • log lines:
    • optional timestamp
    • connection id
    • protocol command
    • sql command (roughly) — which can be multi-line

do you just want to make timestamp not optional and keep the rest as is? it won't be "timestamp for every line of the log", as you can see.

Comment by Sergei Golubchik [ 2023-12-19 ]

I still don't quite understand. You show an excerpt of the MySQL general log. Here's a different excerpt:

/home/a/path/to/mysql/installation/8.0.35/bin/mysqld, Version: 8.0.35 (MySQL Community Server - GPL). started with:
Tcp port: 0  Unix socket: /home/a/path/to/mysql/installation/8.0.35/dt/my.sock
Time                 Id Command    Argument
2023-12-19T12:12:26.478023Z	    8 Connect	root@localhost on  using Socket
2023-12-19T12:12:26.478216Z	    8 Query	select @@version_comment limit 1
2023-12-19T12:12:29.576287Z	    8 Query	select 1
2023-12-19T12:13:10.579917Z	    8 Query	show variables like '%general%'
2023-12-19T12:13:31.775199Z	    8 Query	select
1
as
a

I see here 6 lines without a timestamp and 5 lines with.

Generated at Thu Feb 08 10:15:20 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.