3 ms·
One reason is portability, especially for applications running on both UNIX and Windows. The Windows system event logger is so awful I sometimes think it was ma
by mojuba 19y ago
One reason is portability, especially for applications running on both UNIX and Windows. The Windows system event logger is so awful I sometimes think it was made for robots rather than human programmers. It's just useless.
Why not UNIX syslog? It's a powerful, universal logging tool, optimized for performance, and it can take care of concurrency, repeating message "storms", automatic archiving, etc. It can also store messages pertaining to a particular subsystem in a separate file, and that's what most developers want. The problem is that system configuration must be changed for that (presumably when installing your application) and this is not portable across all UNIX systems, AFAIK.
Why not some widely available libraries then, like you said? Most of them are overcomplicated, don't support concurrency or lack some other very basic, simple features you might need in your project.
So, there's always a temptation to write a custom logger because it looks simple in the beginning - just take the string and write it to a file, right? And it is, in fact, not at all simple if you think of concurrency and performance.
I usually take UNIX syslog as a basis and I write my own syslog emulator on Windows whenever I need to maintain portability of the source.