我引用了此link来将访问信息记录到mysql数据库中。
下面是我的
数据库结构apachelogs.web_access_log
+------------------+----------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------------+----------------------+------+-----+---------+-------+
| id | char(19) | YES | | NULL | |
| agent | varchar(255) | YES | | NULL | |
| bytes_sent | int(10) unsigned | YES | | NULL | |
| child_pid | smallint(5) unsigned | YES | | NULL | |
| cookie | varchar(255) | YES | | NULL | |
| machine_id | varchar(25) | YES | | NULL | |
| request_file | varchar(255) | YES | | NULL | |
| referer | varchar(255) | YES | | NULL | |
| remote_host | varchar(50) | YES | | NULL | |
| remote_logname | varchar(50) | YES | | NULL | |
| remote_user | varchar(50) | YES | | NULL | |
| request_duration | smallint(5) unsigned | YES | | NULL | |
| request_line | varchar(255) | YES | | NULL | |
| request_method | varchar(10) | YES | | NULL | |
| request_protocol | varchar(10) | YES | | NULL | |
| request_time | char(28) | YES | | NULL | |
| request_uri | varchar(255) | YES | | NULL | |
| request_args | varchar(255) | YES | | NULL | |
| server_port | smallint(5) unsigned | YES | | NULL | |
| ssl_cipher | varchar(25) | YES | | NULL | |
| ssl_keysize | smallint(5) unsigned | YES | | NULL | |
| ssl_maxkeysize | smallint(5) unsigned | YES | | NULL | |
| status | smallint(5) unsigned | YES | | NULL | |
| time_stamp | int(10) unsigned | YES | | NULL | |
| virtual_host | varchar(255) | YES | | NULL | |
+------------------+----------------------+------+-----+---------+-------+
从浏览器收到请求后,我看到大多数列值都为NULL
+------+-------+------------+-----------+--------+------------+--------------+---------+-------------+----------------+-------------+------------------+--------------+----------------+------------------+--------------+-------------+--------------+-------------+------------+-------------+----------------+--------+------------+--------------+
| id | agent | bytes_sent | child_pid | cookie | machine_id | request_file | referer | remote_host | remote_logname | remote_user | request_duration | request_line | request_method | request_protocol | request_time | request_uri | request_args | server_port | ssl_cipher | ssl_keysize | ssl_maxkeysize | status | time_stamp | virtual_host |
+------+-------+------------+-----------+--------+------------+--------------+---------+-------------+----------------+-------------+------------------+--------------+----------------+------------------+--------------+-------------+--------------+-------------+------------+-------------+----------------+--------+------------+--------------+
| - | - | 0 | NULL | NULL | NULL | NULL | - | ::1 | NULL | - | 0 | NULL | NULL | HTTP/1.0 | NULL | NULL | NULL | NULL | NULL | NULL | NULL | 408 | 1531980584 | 192.168.4.18 |
+------+-------+------------+-----------+--------+------------+--------------+---------+-------------+----------------+-------------+------------------+--------------+----------------+------------------+--------------+-------------+--------------+-------------+------------+-------------+----------------+--------+------------+--------------+
1 row in set (0.02 sec)
大多数请求参数丢失。让我知道要修改所有属性及其对应值的记录。
谢谢
答案 0 :(得分:0)
由于'id'列宽不匹配,Apache2无法将日志正确写入MySQL数据库。在ngOnInit() {
this.uploadPersonInfo();
}
表中创建的默认宽度为19,应增加为25。
完成此操作后,MySQL日志将自动开始更新,而没有任何其他问题。