Skip to content

Logdy as a Systemd service

First, it's a good practice to create a dedicated system user for running Logdy.dev. This improves security by limiting the permissions available to the Logdy.dev process.

Download Logdy on a target system

Logdy installation

Naviagate to docs for instructions on how to install Logdy. You can download a precompiled library, install using script or homebrew, lastly you can compile Logdy yourself.

(optional) Create a dedicated user to run Logdy

bash
sudo useradd -r -s /bin/false logdy

The command above creates a system user named Logdy with no login shell.

Systemd file definition

Next, we need to create a service definition in a specific location, open a file with your text editor at the location below:

bash
sudo nano /etc/systemd/system/logdy.service

and paste the contents below:

ini
[Unit]
Description=Logdy Service
After=network.target

[Service]
User=logdy # or root if you wish to run as a root user
Group=logdy # or root

# the absolute path to Logdy binary
ExecStart=/usr/local/bin/logdy listen 8123 \
    # Setup password for accessing the UI
    --ui-pass=foobar \

    --port=8081 \

    # IP of the machine accessible through the network
    --ui-ip=XXXX 

Restart=on-failure
RestartSec=10

[Install]
WantedBy=multi-user.target

Run Logdy in different modes

You can also run Logdy in a different mode, for example follow can track newly added lines to multiple files.

Enable and run Logdy systemd service

Use the command below to reload systemd so it can pick up a newly added service definition:

bash
sudo systemctl daemon-reload

Enable Logdy service so it's started after a reboot:

bash
sudo systemctl enable logdy

Start the service (you only have to do it once)

bash
sudo systemctl start logdy

Check the status:

bash
sudo systemctl status logdy

If the installation was successful, you should see a similar output to the one below.

bash
root@vps:~# service logdy status
 logdy.service - Logdy Service
   Loaded: loaded (/etc/systemd/system/logdy.service; enabled; vendor preset: enabled)
   Active: active (running) since Thu 2024-06-27 22:18:13 CEST; 2s ago
 Main PID: 22836 (logdy)
   CGroup: /system.slice/logdy.service
           └─22836 /usr/local/bin/logdy socket 8123 --ui-pass=foobar --port=8081 --ui-ip=[redacted]

Jun 27 22:18:13 systemd[1]: Started Logdy Service.
Jun 27 22:18:13 logdy[22836]: time="22:18:13.129" level=warning msg="No opt-out from analytics, we'll be receiving anonymous usage data, which will be used to improve the product. To opt-out use the flag --no-analytics."
Jun 27 22:18:13 logdy[22836]: time="22:18:13.136" level=info msg="WebUI started, visit http://[redacted]:8081" port=8081
Jun 27 22:18:13 logdy[22836]: time="22:18:13.137" level=info msg="TCP Server is listening" address=":8123"

Enter Logdy UI

Your Logdy instance has been installed and now you can navigate to the UI, enter http://[IP]:8081 address

Start producing logs

Now, anything that will send content to 8123 port, will be picked up by Logdy. We can use logdy forward command to setup a tail -f on a log file and forward it to Logdy instance.

bash
$ tail -f /var/log/auth.log | logdy forward 8123

You can alternatively use netcat to test the setup, just run the command and start typing the messages to be send followed by Enter.

bash
$ nc localhost 8123
foobar1
foobar2

Check Logdy logs

If at any point you would like to check Logdy logs, you can use journalctl command (check this blog post how to use it). The command below will print the logs and follow newly added lines in real-time.

bash
$ journalctl -u logdy.service -f