Windows Subsystem for Linux (WSL) allows you to run Linux applications on a Windows host. While you can install and run syslog-ng on a default WSL installation, it is not really practical: there is no systemd and WSL is behind NAT. This blog gives you some pointers for working around these problems.
For many years, if you wanted to work with WSL, you had to find information in various forums, blog posts, or mailing list archives. Not anymore: Microsoft made using WSL easier and even prepared proper documentation for it. Throughout this blog, I will refer to various sub-pages of https://learn.microsoft.com/en-us/windows/wsl/
Before you begin
First of all, make sure that WSL 2 is installed on your Windows machine. You also need to install one of the Linux distributions. My choice is openSUSE Leap, but the same instructions should work on any of the supported Linux distributions. Once you installed Linux, do not install syslog-ng yet!
Enabling systemd
Before you install syslog-ng, make sure that systemd is enabled in WSL. It is not enabled by default to make WSL start (a lot) faster. Check https://learn.microsoft.com/en-us/windows/wsl/systemd on how to enable systemd support within WSL.
Install and configure syslog-ng
Once you restarted WSL verify that you are using systemd: start systemctl. Running it without any arguments is good enough: if you do not get a big red warning, then you are OK.
Now it is time to install syslog-ng according to your Linux distribution of choice. In my case it was:
zypper -v in syslog-ng
Make sure that a network source is available in your configuration and that it is enabled in a log path:
tcp(ip("0.0.0.0") port(514));
Then, restart syslog-ng:
systemctl restart syslog-ng
Configuring networking
By default, WSL is behind NAT. Unfortunately, because of company policy, I have Windows 10 on my laptop, which is a lot less flexible. Windows 11 has a lot more possibilities to provide network services from WSL to the outside world.
All possibilities are described at https://learn.microsoft.com/en-us/windows/wsl/networking
In my case, I adopted the following command line to forward log messages into WSL:
netsh interface portproxy add v4tov4 listenport=<yourPortToForward> listenaddress=0.0.0.0 connectport=<yourPortToConnectToInWSL> connectaddress=(wsl hostname -I)
What is next?
Your mileage may vary, but despite my workarounds, when it comes to Windows, I still find it a lot easier to install syslog-ng on a proper virtual machine. However, my preferences might be just because of the Windows 10 limitations I mentioned. As such, if you use WSL regularly anyway, then running syslog-ng in it might be still a good alternative to deploying a full-fledged virtual machine.
-
If you have questions or comments related to syslog-ng, do not hesitate to contact us. You can reach us by email or even chat with us. For a list of possibilities, check our GitHub page under the “Community” section at https://github.com/syslog-ng/syslog-ng. On Twitter, I am available as @PCzanik, on Mastodon as @Pczanik@fosstodon.org.