~fkooman/vpn-documentation

385eaf28397f429e015fb2f4cdcb2e3d7e0376cf — François Kooman a month ago e000095
update logging docs
1 files changed, 19 insertions(+), 14 deletions(-)

M LOGGING.md
M LOGGING.md => LOGGING.md +19 -14
@@ 42,30 42,35 @@ Jul 12 16:48:43 vpn.tuxed.net vpn-server-api[8643]: CONNECT fkooman (default) [1
Jul 12 16:48:46 vpn.tuxed.net vpn-server-api[8642]: DISCONNECT fkooman (default) [10.202.56.2,fd5e:eccc:d4b:783f::1000]
```

The format is 
`{CONNECT,DISCONNECT} ${USER_ID} (${PROFILE_ID}) [${IPv4},${IPv6}]`.
The default format is:

```
{{EVENT_TYPE}} {{USER_ID}} ({{PROFILE_ID}}) [{{IP_FOUR}},{{IP_SIX}}]
```

**NOTE**: starting from vpn-server-api >= 2.2.12 there is flexibility in the 
way the log is written. A template can be configured. The default is format 
way the log is written. A template can be configured. The default is the format 
shown above. This version also adds the ability to log the "originating IP" of
the VPN client.

You can set the `connectionLogFormat` in `/etc/vpn-server-api/config.php` to 
a string that is used as a template for generating the log lines. The default 
is `{{EVENT_TYPE}} {{USER_ID}} ({{PROFILE_ID}}) [{{IP_FOUR}},{{IP_SIX}}]`. You 
can customize this and use the following "variables" that are replaced before 
a string that is used as a template for generating the log lines. You can 
customize this and use the following "variables" that are replaced before 
writing the log line:

* `EVENT_TYPE`: either `CONNECT` or `DISCONNECT`;
* `USER_ID`: the user ID;
* `PROFILE_ID`: the profile that is being connected to;
* `IP_FOUR`: the IPv4 addresses provided to the VPN client;
* `IP_SIX`: the IPv6 addresses provided to the VPN client;
* `ORIGINATING_IP`: the IP address (either IPv4 or IPv6) the VPN client is 
* `{{EVENT_TYPE}}`: either `CONNECT` or `DISCONNECT`;
* `{{USER_ID}}`: the user ID;
* `{{PROFILE_ID}}`: the profile that is being connected to;
* `{{IP_FOUR}}`: the IPv4 addresses provided to the VPN client;
* `{{IP_SIX}}`: the IPv6 addresses provided to the VPN client;
* `{{ORIGINATING_IP}}`: the IP address (either IPv4 or IPv6) the VPN client is 
  connecting _from_.

Make sure you "wrap" the variable in `{{` and `}}` as shown in the example 
above when using them in `connectionLogFormat`.
Another example, where the originating IP is also logged could be:

```
{{EVENT_TYPE}} {{USER_ID}} ({{PROFILE_ID}}) [{{ORIGINATING_IP}} => {{IP_FOUR}},{{IP_SIX}}]
```

## Web Server Log