Tail your server logs with a web UI

Sometimes, well, often, I like to monitor my application logs, without ssh’ing into the server. Usually on the go!

Although there are many “industry standard” logging solutions out there, most times, they’re not easiest to roll out and or maintain, and typically aren’t even resource-friendly.

I was recently introduced to Logdy. I got it. I tried it. And here’s how to get going with a UI interface for your logs tailing in no time, and will even throw in a system service so as to keep it running after system restart.

Logdy

Head over to the official docs for all the different ways you can possibly massage Logdy, or their website to learn about the tool in general.

In my case, I got up and running quickest using the steps I outline below.

$ curl https://logdy.dev/install.sh | sudo sh

Then, I follow all the logs I want to load. These can be all logs from different applications i.e gunicorn, nginx, pm2, rails, etc

Let’s say I want to tail my nginx and gunicorn logs

$ logdy follow /path/to/gunicorn.log /path/to/nginx.log --port 8080 --ui-ip 0.0.0.0 --ui-pass mypassword
....
INFO[...] WebUI started, visit http://0.0.0.0:8080    port=8080

The above command starts the logdy service on port 8080.

If you have your firewall port 8080 open (or open with ufw allow 8080/tcp), you should be able to then visit in your browser at yourdomain-or-ip:8080

The last step I do is make the command into a service /etc/systemd/system/logdy.service

[Unit]
Description=Logdy Log Monitoring Service
After=network.target

[Service]
User=<your-username>
Group=<your-usergroup>
User=nobody  # Adjust the user if you need to run it as a different user
WorkingDirectory=/usr/local/bin  # Assuming logdy is in this directory 
ExecStart=/usr/local/bin/logdy follow /path/to/gunicorn.log /path/to/nginx.log --port 8080 --ui-ip 127.0.0.1 --ui-pass mypassword
Restart=on-failure

[Install]
WantedBy=multi-user.target

Then:

$ sudo systemctl daemon-reload
$ sudo systemctl start logdy
$ sudo systemctl enable logdy

Optional step (Nginx Proxy)

Perhaps you’d wanna run the service on a subdomain, and proxy requests from Nginx to logdy. Great.

server {
    listen 80;
    server_name logdy.yourdomain.com;  # Replace with your desired hostname

    location / {
        proxy_pass http://127.0.0.1:8080;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}

And then

$ sudo ln -s /etc/nginx/sites-available/logdy.conf /etc/nginx/sites-enabled/logdy.conf

$ sudo nginx -t  # Test configuration
$ sudo systemctl reload nginx

Conclusion

The entire process above took me about 3-5 minutes on my first try. Logdy is open source, and looking forward to your support, ideas and PRs.

Exit mobile version