On Mon, 31 Mar 2025 13:06:46 +0200, Bo Berglund <bo.bergl...@gmail.com> wrote:
>But I have one remaining issue, missing timestamps: >--------------------------------------------------- > >The OpenVPN server's logfile and status logfile are *missing timestamps*, which >makes them difficult to use for troubleshooting. > >How can I make each line in the logs start with a timestamp that can be used >for >sorting/searching, like so: > >2025-03-31 10:22:19 Some log info > >(Notice that the most significant item is at the start and the least in the end >contrary to the useless USA way of printing complete date-times...) > >I tried by adding this to the server.conf file: > >suppress-timestamps no > >which was suggested to me online... > >But that caused the server to not start at all! > >In the log: > >$ sudo cat server.log >Options error: Unrecognized option or missing or extra parameter(s) in >server.conf:42: suppress-timestamps (2.6.3) >Use --help for more information. > > >And no more logging since the server apparently choked on this. > >Took a while to find this out. >And using the openvpn --help did not help much either. > > >Now I have looked around in searches and found that apparently my server and >serverlocal services are controlled by systemd using this common file for the >services: > >/usr/lib/systemd/system/openvpn-server@.service > >And on my new system that file contains this: > >ExecStart=/usr/sbin/openvpn --status %t/openvpn-server/status-%i.log >--status-version 2 --suppress-timestamps --config %i.conf > >Notice the --suppress-timestamps item, which I belive is what removes the >timestamp output. > >Question: >--------- >Is it safe to edit that file and remove --suppress-timestamp (and I assume >restart the openvpn instances)? > >Or can this cause havoc in my system? > >And how is the timestamp format defined? I finally found online what the least intrusive solution is, so it can be selectively applied to one of several servers running on the same machine. It creates an override for the standard ExecStart commend for selected service instances: 1) Locate the /usr/lib/systemd/system/openvpn-server@.service template file 2) Open it and copy out the line ExecStart= (it contains the --suppress-timestamps item) in my case it looks like this: ExecStart=/usr/sbin/openvpn --status %t/openvpn-server/status-%i.log --status-version 2 --suppress-timestamps --config %i.conf 3) Create an override dir: sudo mkdir -p /etc/systemd/system/openvpn-server@xxxx.service.d where xxxx is the name of the conf file, in my case "server". 3) Create an "override" file: sudo nano /etc/systemd/system/openvpn-server@xxxx.service.d/override.conf where again xxxx is replaced by the name of the conf file 4) Paste this into the file (the active line content from step 2 above minus the suppress-timestamps argument. It will look like this: [Service] ExecStart= ExecStart=/usr/sbin/openvpn --status /run/openvpn-server/status-server.log --status-version 2 --config /etc/openvpn/server/server.conf Now when the service is restarted the ExecStart item is first reset to blank and then filled with the original but minus the --suppress-timestamps argument. I have not yet had time to actually test/verify this but I am writing it down to check later (so I don't forget the method). Hopefully this can be the solution that is OK to use. -- Bo Berglund Developer in Sweden _______________________________________________ Openvpn-users mailing list Openvpn-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openvpn-users