4.2.2 How to collect logs
This subsection describes how to collect the access log, error log, process ID log, and request log.
- Organization of this subsection
(1) Access log
(a) Access log in the default format
Specify the TransferLog directive to acquire the log.
The following is an example of access log in the default format:
Client host nameΔIdentification information of the clientΔClient user nameΔAccess timeΔ"request line"ΔStatus codeΔNumber of sent bytes
- Legend:
-
Δ: Space
- (Output example)
172.17.40.30 - - [25/Dec/2000:16:23:59 +0900] "GET / HTTP/1.0" 200 3546
(b) Access log of custom format
Specify the CustomLog directive and collect the log. There are two methods to specify format:
-
Specify the format directly in the CustomLog directive
- (Example)
-
CustomLog logs/access.log "%h %l %u %t \"%r\" %>s %b"
-
Define a label name for the format with the LogFormat directive, and specify this label name in the CustomLog directive
- (Example)
-
LogFormat "%h %l %u %t \"%r\" %>s %b" common
CustomLog logs/access.log common
(2) Error log
(a) Error message log
Specify the ErrorLog directive and collect the log. Specify the level of the errors to be collected with the LogLevel directive.
(b) The CGI script error log
Specify the ScriptLog directive and collect the CGI script error log.
(3) Process ID log
Specify the PidFile directive and collect the control process ID log.
If you create multiple environments, make sure that a different file path is used for each environment.
(4) request log
Specify the HWSRequestLog and the HWSRequestLogType directives to collect the request log. The request log is a generic name that refers to module trace information, request trace information, and I/O filter trace information.
For details on module trace information, see 4.2.6 Collecting the module trace. For details on request trace information, see 4.2.7 Collecting request trace information. For details on I/O filter trace information, see 4.2.8 Collecting I/O filter trace information.
(5) WebSocket log
(a) How to specify
Specify the HWSWebSocketLog directive to collect log data in WebSocket communication.
The following is an example of dividing the file by 512 MB by using the rotatelogs2 program.
HWSWebSocketLog "|installation-path/httpsd/sbin/rotatelogs2 log-output-destination/hws_websocket_log 524288 2"
To specify the HWSWebSocketLog directive, you need to embed the mod_proxy_wstunnel module. For details on how to embed this module, see 4.15.1 mod_proxy_wstunnel module. If the mod_proxy_wstunnel module is not embedded, a startup error occurs.
(b) Output formats
Log information output in each WebSocket communication contains the root AP information. However, if the root AP information cannot be acquired, - will be output for root-AP-information. The following shows the formats of output log information.
-
When data is successfully sent from the client to the backend server
[time]Δ(ID)Δclient-IP:portΔ-->ΔWeb-server-IP:portΔ-->ΔWeb-server-IP:portΔ-->Δback-IP:portΔ(root-AP-information)
-
When data is successfully sent from the backend server to the client (first time)
[time]Δ(ID)Δclient-IP:portΔ<--ΔWeb-server-IP:portΔ<--ΔWeb-server-IP:portΔ<--Δback-IP:portΔ(root-AP-information)(status-code)
Note, however, that if the status code cannot be acquired, -1 will be displayed for status-code.
-
When data is successfully sent from the backend server to the client (second time or later)
[time]Δ(ID)Δclient-IP:portΔ<--ΔWeb-server-IP:portΔ<--ΔWeb-server-IP:portΔ<--Δback-IP:portΔ(root-AP-information)
-
When an error occurred while data was being received from the client
[time]Δ(ID)Δclient-IP:portΔ-X-ΔWeb-server-IP:portΔ-->ΔWeb-server-IP:portΔ---Δback-IP:portΔ(root-AP-information)
-
When an error occurred while data was being sent to the backend server
[time]Δ(ID)Δclient-IP:portΔ-->ΔWeb-server-IP:portΔ-X-ΔWeb-server-IP:portΔ-X-Δback-IP:portΔ(root-AP-information)
-
When an error occurred while data was being received from the backend server
[time]Δ(ID)Δclient-IP:portΔ---ΔWeb-server-IP:portΔ<--ΔWeb-server-IP:portΔ-X-Δback-IP:portΔ(root-AP-information)
-
When an error occurred while data was being sent to the client
[time]Δ(ID)Δclient-IP:portΔ-X-ΔWeb-server-IP:portΔ<--ΔWeb-server-IP:portΔ<--Δback-IP:portΔ(root-AP-information)
-
When a disconnected connection with the backend server is detected
[time]Δ(ID)Δclient-IP:portΔ---ΔWeb-server-IP:portΔ---ΔWeb-server-IP:portΔ-X-Δback-IP:portΔ(root-AP-information)
-
When a disconnected connection with the client is detected
[time]Δ(ID)Δclient-IP:portΔ-X-ΔWeb-server-IP:portΔ---ΔWeb-server-IP:portΔ---Δback-IP:portΔ(root-AP-information)
- Legend:
-
Δ: Space
-->: Flow of data from the client to the backend server
<--: Flow of data from the backend server to the client
-X-: Error when sending or receiving data, or disconnection of the connection
---: No event
(Output example)
[Mon Dec 09 21:13:09.008 2019] (9796) 192.168.10.10:61682 --> 192.168.10.20:80 --> 192.168.10.20:61683 --> 192.168.10.30:8008 (192.168.10.20/14756/0x0000000000000087) [Mon Dec 09 21:13:09.019 2019] (9796) 192.168.10.10:61682 <-- 192.168.10.20:80 <-- 192.168.10.20:61683 <-- 192.168.10.30:8008 (192.168.10.20/14756/0x0000000000000087)(101) [Mon Dec 09 21:13:09.029 2019] (9796) 192.168.10.10:61682 <-- 192.168.10.20:80 <-- 192.168.10.20:61683 <-- 192.168.10.30:8008 (192.168.10.20/14756/0x0000000000000087) [Mon Dec 09 21:13:10.715 2019] (9796) 192.168.10.10:61682 --> 192.168.10.20:80 --> 192.168.10.20:61683 --> 192.168.10.30:8008 (192.168.10.20/14756/0x0000000000000087) [Mon Dec 09 21:13:10.727 2019] (9796) 192.168.10.10:61682 <-- 192.168.10.20:80 <-- 192.168.10.20:61683 <-- 192.168.10.30:8008 (192.168.10.20/14756/0x0000000000000087) [Mon Dec 09 21:13:12.227 2019] (9796) 192.168.10.10:61682 --> 192.168.10.20:80 --> 192.168.10.20:61683 --> 192.168.10.30:8008 (192.168.10.20/14756/0x0000000000000087) [Mon Dec 09 21:13:12.234 2019] (9796) 192.168.10.10:61682 <-- 192.168.10.20:80 <-- 192.168.10.20:61683 <-- 192.168.10.30:8008 (192.168.10.20/14756/0x0000000000000087) [Mon Dec 09 21:13:12.236 2019] (9796) 192.168.10.10:61682 --- 192.168.10.20:80 --- 192.168.10.20:61683 -X- 192.168.10.30:8008 (192.168.10.20/14756/0x0000000000000087)
(6) Locations to which trace information is output
(a) Module trace information output destination
Module trace information is output to either the error log or the request log. The specification of directives determines which log is used for outputting module trace information. The following table lists the module trace information output destinations and conditions.
For details on module trace information, see 4.2.6 Collecting the module trace.
(b) Output destination of request trace information and I/O filter trace information
Request trace information and I/O filter trace information are output to the request log.
When the HWSRequestLog directive is specified and the HWSRequestLogType directive satisfies the output conditions, the trace information is output to the request log. For details on the output conditions of the HWSRequestLogType directive, see 4.2.7 Collecting request trace information and 4.2.8 Collecting I/O filter trace information.