The advantages of using syslog where available (all modern *nix systems, including Linux, FreeBSD, OS-X etc.) are numerous:
- Performance is better: syslog is compiled C and most importantly it works as a separate process so all your logging operations become non-blocking to the applications, processes, and threads that make them
- You can log from multiple processes/threads concurrently without worrying about locking. All logging is safely serialized for you so you don't lose data
- You get standard sortable time-stamps on all logged lines for free
- You get log rotation for free
- You get severity level support for free (see
man syslog
)
- You can call logging from any language with a C binding, which is virtually any language
- You can trivially log from shell scripts or command line (via
logger
)
- You don't need to reinvent the (how to log) wheel
The only disadvantage I can think of is that syslog
is non portable (to non *nix systems), but if you're on any modern *nix, any alternative is more complicated and likely less reliable.
The concern of losing packets because syslog
is using UDP may be valid, but in practice on a LAN, I've never found it to be an issue.