Created
July 24, 2025 12:59
-
-
Save DavesCodeMusings/89a5a39b0f2d5dca90a6e3b1e843835c to your computer and use it in GitHub Desktop.
syslog-ng in Docker for logging network hosts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Creates a syslog server that can be used to centrally collect logs from various network devices. | |
| You'll need a Docker compose project directory structure that looks like this: | |
| -rw-r--r-- 1 root root 351 Jul 24 12:00 compose.yml | |
| drwxr-xr-x 3 1000 1000 4096 Jul 24 12:00 config/ | |
| drwxr-xr-x 2 1000 1000 4096 Jul 24 12:00 logs/ | |
| The syslog-ng.conf goes in the config/ directory. Logs will be found in the logs/ directory. | |
| Logs are rotated daily. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --- | |
| services: | |
| syslog-ng: | |
| image: lscr.io/linuxserver/syslog-ng:latest | |
| container_name: syslog-ng | |
| environment: | |
| - PUID=1000 | |
| - PGID=1000 | |
| - TZ=Etc/UTC | |
| volumes: | |
| - ./config:/config | |
| - ./logs:/var/log | |
| ports: | |
| - 514:514/udp | |
| - 514:514/tcp | |
| restart: unless-stopped | |
| ~ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @version:4.8 | |
| source s_udp_514 { | |
| network(transport("udp") port(514)); | |
| }; | |
| source s_tcp_514 { | |
| network(transport("tcp") port(514)); | |
| }; | |
| destination d_mesg { | |
| file("/var/log/$YEAR$MONTH$DAY.log"); | |
| }; | |
| log { | |
| source(s_udp_514); | |
| destination(d_mesg); | |
| }; | |
| log { | |
| source(s_tcp_514); | |
| destination(d_mesg); | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment