Matthias Sohn | 450bc20 | 2020-08-20 14:40:32 +0200 | [diff] [blame] | 1 | = Gerrit Code Review - Logs |
| 2 | |
| 3 | Gerrit writes log files in the `$site_path/logs/` folder tracking requests, |
| 4 | background and plugin activity and errors. By default logs are written in |
| 5 | link:config-gerrit.html#log.textLogging[text format], optionally in |
| 6 | link:config-gerrit.html#log.jsonLogging[JSON format]. |
| 7 | By default log files are link:config-gerrit.html#log.compress[compressed] |
| 8 | at server startup and then daily at 11pm and |
| 9 | link:config-gerrit.html#log.rotate[rotated] every midnight. |
| 10 | |
Sven Selberg | a46c81e | 2020-09-10 16:19:17 +0200 | [diff] [blame] | 11 | == Time format |
| 12 | |
| 13 | For all timestamps the format `[yyyy-MM-dd'T'HH:mm:ss,SSSXXX]` is used. |
| 14 | This format is both link:https://www.w3.org/TR/NOTE-datetime[ISO 8601] and |
| 15 | link:https://tools.ietf.org/html/rfc3339[RFC3339] compatible. |
| 16 | |
Matthias Sohn | 450bc20 | 2020-08-20 14:40:32 +0200 | [diff] [blame] | 17 | == Logs |
| 18 | |
| 19 | The following logs can be written. |
| 20 | |
| 21 | === HTTPD Log |
| 22 | |
| 23 | The httpd log tracks HTTP requests processed by Gerrit's http daemon |
| 24 | and is written to `$site_path/logs/httpd_log`. Enabled or disabled via the |
| 25 | link:config-gerrit.html#httpd.requestLog[httpd.requestLog] option. |
| 26 | |
| 27 | Format is an enhanced |
| 28 | link:https://httpd.apache.org/docs/2.4/logs.html#combined[NCSA combined log], |
| 29 | if a log field is not present, a "-" is substituted: |
| 30 | |
| 31 | * `host`: The IP address of the HTTP client that made the HTTP resource request. |
| 32 | If you are using a reverse proxy it depends on the proxy configuration if the |
| 33 | proxy IP address or the client IP address is logged. |
| 34 | * `[thread name]`: name of the Java thread executing the request. |
| 35 | * `remote logname`: the identifier used to |
| 36 | link: https://tools.ietf.org/html/rfc1413[identify the client making the HTTP request], |
| 37 | Gerrit always logs a dash `-`. |
| 38 | * `username`: the username used by the client for authentication. "-" for |
| 39 | anonymous requests. |
| 40 | * `[date:time]`: The date and time stamp of the HTTP request. |
Sven Selberg | a46c81e | 2020-09-10 16:19:17 +0200 | [diff] [blame] | 41 | The time that the request was received. |
Matthias Sohn | 450bc20 | 2020-08-20 14:40:32 +0200 | [diff] [blame] | 42 | * `request`: The request line from the client is given in double quotes. |
| 43 | ** the HTTP method used by the client. |
| 44 | ** the resource the client requested. |
| 45 | ** the protocol/version used by the client. |
| 46 | * `statuscode`: the link:https://tools.ietf.org/html/rfc2616#section-10[HTTP status code] |
| 47 | that the server sent back to the client. |
| 48 | * `response size`: the number of bytes of data transferred as part of the HTTP |
| 49 | response, not including the HTTP header. |
| 50 | * `latency`: response time in milliseconds. |
| 51 | * `referer`: the `Referer` HTTP request header. This gives the site that |
| 52 | the client reports having been referred from. |
| 53 | * `client agent`: the client agent which sent the request. |
Matthias Sohn | 5c48b66 | 2021-03-25 14:29:00 +0100 | [diff] [blame] | 54 | * `total_cpu`: total CPU time, CPU time in milliseconds to execute command. |
| 55 | * `user_cpu`: user mode CPU time, CPU time in user mode in milliseconds to execute command. |
| 56 | CPU time in kernel mode is `total_cpu - user_cpu`. |
Matthias Sohn | 78f204c | 2021-03-25 14:02:13 +0100 | [diff] [blame] | 57 | * `memory`: memory allocated in bytes to execute command. -1 if the JVM does |
| 58 | not support this metric. |
Antonio Barone | 05c86d9 | 2021-09-01 10:52:32 +0200 | [diff] [blame] | 59 | * `command status`: the overall result of the git command over HTTP. Currently |
| 60 | populated only for the transfer phase of `git-upload-pack` commands. |
| 61 | Possible values: |
| 62 | ** `-1`: The `git-upload-pack` transfer was ultimately not successful |
| 63 | ** `0`: The `git-upload-pack` transfer was ultimately successful |
Matthias Sohn | 450bc20 | 2020-08-20 14:40:32 +0200 | [diff] [blame] | 64 | |
| 65 | Example: |
| 66 | ``` |
| 67 | 12.34.56.78 [HTTP-4136374] - johndoe [28/Aug/2020:10:02:20 +0200] "GET /a/plugins/metrics-reporter-prometheus/metrics HTTP/1.1" 200 1247498 1900 - "Prometheus/2.13.1" |
| 68 | ``` |
| 69 | |
| 70 | === SSHD Log |
| 71 | |
| 72 | The sshd log tracks ssh requests processed by Gerrit's ssh daemon |
| 73 | and is written to `$site_path/logs/sshd_log`. Enabled or disabled |
| 74 | via option link:config-gerrit.html#sshd.requestLog[sshd.requestLog]. |
| 75 | |
| 76 | Log format: |
| 77 | |
| 78 | * `[date time]`: The time that the request was received. |
Matthias Sohn | 450bc20 | 2020-08-20 14:40:32 +0200 | [diff] [blame] | 79 | * `sessionid`: hexadecimal session identifier, all requests of the |
| 80 | same connection share the same sessionid. Gerrit does not support multiplexing multiple |
| 81 | sessions on the same connection. Grep the log file using the sessionid as filter to |
| 82 | get all requests from that session. |
| 83 | * `[thread name]`: name of the Java thread executing the request. |
| 84 | * `username`: the username used by the client for authentication. |
| 85 | * `a/accountid`: identifier of the Gerrit account which is logged on. |
| 86 | * `operation`: the operation being executed via ssh. |
| 87 | ** `LOGIN FROM <host>`: login and start new SSH session from the given host. |
| 88 | ** `AUTH FAILURE FROM <host> <message>`: failed authentication from given host and cause of failure. |
| 89 | ** `LOGOUT`: logout and terminate SSH session. |
| 90 | ** `git-upload-pack.<projectname>`: git fetch or clone command for given project. |
| 91 | ** `git-receive-pack.<projectname>`: git push command for given project. |
| 92 | ** Gerrit ssh commands which may be logged in this field are documented |
| 93 | link:cmd-index.html#_server[here]. |
| 94 | * `wait`: command wait time, time in milliseconds the command waited for an execution thread. |
| 95 | * `exec`: command execution time, time in milliseconds to execute the command. |
| 96 | * `status`: status code. 0 means success, any other value is an error. |
Matthias Sohn | 74f5f40 | 2021-03-24 15:42:16 +0100 | [diff] [blame] | 97 | * `total_cpu`: total CPU time, CPU time in milliseconds to execute command. |
| 98 | * `user_cpu`: user mode CPU time, CPU time in user mode in milliseconds to execute command. |
| 99 | CPU time in kernel mode is `total_cpu - user_cpu`. |
Matthias Sohn | 532416f | 2021-03-24 17:56:00 +0100 | [diff] [blame] | 100 | * `memory`: memory allocated in bytes to execute command. -1 if the JVM does |
| 101 | not support this metric. |
Matthias Sohn | 450bc20 | 2020-08-20 14:40:32 +0200 | [diff] [blame] | 102 | |
| 103 | The `git-upload-pack` command provides the following additional fields after the `exec` |
| 104 | and before the `status` field. All times are in milliseconds. Fields are -1 if not available |
| 105 | when the upload-pack request returns an empty result since the client's repository was up to date: |
| 106 | |
| 107 | * `time negotiating`: time for negotiating which objects need to be transferred. |
| 108 | * `time searching for reuse`: time jgit searched for deltas which can be reused. |
| 109 | That is the time spent matching existing representations against objects that |
| 110 | will be transmitted, or that the client can be assumed to already have. |
| 111 | * `time searching for sizes`: time jgit was searching for sizes of all objects that |
| 112 | will enter the delta compression search window. The sizes need to |
| 113 | be known to better match similar objects together and improve |
| 114 | delta compression ratios. |
| 115 | * `time counting`: time jgit spent enumerating the objects that need to |
| 116 | be included in the output. This time includes any restarts that |
| 117 | occur when a cached pack is selected for reuse. |
| 118 | * `time compressing`: time jgit was compressing objects. This is observed |
| 119 | wall-clock time and does not accurately track CPU time used when |
| 120 | multiple threads were used to perform the delta compression. |
| 121 | * `time writing`: time jgit needed to write packfile, from start of |
| 122 | header until end of trailer. The transfer speed can be |
| 123 | approximated by dividing `total bytes` by this value. |
| 124 | * `total time in UploadPack`: total time jgit spent in upload-pack. |
| 125 | * `bitmap index misses`: number of misses when trying to use bitmap index, |
| 126 | -1 means no bitmap index available. This is the count of objects that |
| 127 | needed to be discovered through an object walk because they were not found |
| 128 | in bitmap indices. |
| 129 | * `total deltas`: total number of deltas transferred. This may be lower than the actual |
| 130 | number of deltas if a cached pack was reused. |
| 131 | * `total objects`: total number of objects transferred. This total includes |
| 132 | the value of `total deltas`. |
| 133 | * `total bytes`: total number of bytes transferred. This size includes the pack |
| 134 | header, trailer, thin pack, and reused cached packs. |
| 135 | * `client agent`: the client agent and version which sent the request. |
| 136 | |
| 137 | Example: a CI system established a SSH connection, sent an upload-pack command (git fetch) and closed the connection: |
| 138 | ``` |
| 139 | [2020-08-28 11:00:01,391 +0200] 8a154cae [sshd-SshServer[570fc452]-nio2-thread-299] voter a/1000023 LOGIN FROM 12.34.56.78 |
| 140 | [2020-08-28 11:00:01,556 +0200] 8a154cae [SSH git-upload-pack /AP/ajs/jpaas-msg-svc.git (voter)] voter a/1000056 git-upload-pack./demo/project.git 0ms 115ms 92ms 1ms 0ms 6ms 0ms 0ms 7ms 3 10 26 2615 0 git/2.26.2 |
| 141 | [2020-08-28 11:00:01,583 +0200] 8a154cae [sshd-SshServer[570fc452]-nio2-thread-168] voter a/1000023 LOGOUT |
| 142 | ``` |
| 143 | |
| 144 | === Error Log |
| 145 | |
| 146 | The error log tracks errors and stack traces and is written to |
| 147 | `$site_path/logs/error_log`. |
| 148 | |
| 149 | Log format: |
| 150 | |
| 151 | * `[date time]`: The time that the request was received. |
Matthias Sohn | 450bc20 | 2020-08-20 14:40:32 +0200 | [diff] [blame] | 152 | * `[thread name]`: : name of the Java thread executing the request. |
| 153 | * `level`: log level (ERROR, WARN, INFO, DEBUG). |
| 154 | * `logger`: name of the logger. |
| 155 | * `message`: log message. |
| 156 | * `stacktrace`: Java stacktrace when an execption was caught, usually spans multiple lines. |
| 157 | |
| 158 | === GC Log |
| 159 | |
| 160 | The gc log tracks git garbage collection running in a background thread |
| 161 | if enabled and is written to `$site_path/logs/gc_log`. |
| 162 | |
| 163 | Log format: |
| 164 | |
| 165 | * `[date time]`: The time that the request was received. |
Matthias Sohn | 450bc20 | 2020-08-20 14:40:32 +0200 | [diff] [blame] | 166 | * `level`: log level (ERROR, WARN, INFO, DEBUG). |
| 167 | * `message`: log message. |
| 168 | |
| 169 | === Plugin Logs |
| 170 | |
| 171 | Some plugins write their own log file. |
| 172 | E.g. the replication plugin writes its log to `$site_path/logs/replication_log`. |
| 173 | Refer to each plugin's documentation for more details on their logs. |
| 174 | |
| 175 | GERRIT |
| 176 | ------ |
| 177 | Part of link:index.html[Gerrit Code Review] |
| 178 | |
| 179 | SEARCHBOX |
| 180 | --------- |