mysql有一个功能就是可以log下来运行的比较慢的sql语句,默认是没有这个log的
打开
my.ini
,找到
[mysqld]
在其下面添加
long_query_time
=
2
log-slow-queries
=
log=e:/wamp/logs/mysql-log.log
#设置把日志写在那里,可以为空,系统会给一个缺省的文件
#log-slow-queries
=
/var/youpath/slow.log
linux下host_name-slow.log
注意目录的权限要可写。
System.out.println( new ReadSingleLineNumber().test2())}
MySqlLog test2(){
String log = "2018-03-21T13:46:01.185376Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details)."
String[] head = log.substring(0, log.indexOf(']') + 1).split(" ")
return new MySqlLog(head[0].trim(), Integer.parseInt(head[1].trim()), head[2].trim().substring(head[2].trim().indexOf('[') + 1, head[2].trim().indexOf(']')), log.substring(log.indexOf(']') + 2).trim())
}
class MySqlLog{
String time
int index
String level
String msg
public MySqlLog(String time, int index, String level, String msg) {
this.time = time
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)