C++ logging on Windows and UNIX

Started by
6 comments, last by Katie 13 years, 3 months ago
I recently merged a Linux and Windows program. To get it working I commented out some calls to syslog. I'm wanting now to add the logging back. The software needs to run on UNIX and Windows, but I don't anticipate it having to run on other operating systems. The merged program isn't using Boost at this point and I'm not wanting to use the Boost logging library on this. Any other lighter weight suggestions? Thanks in advance.

Brian Wood
Ebenezer Enterprises
http://webEbenezer.net
Advertisement
what about std::clog?
Exitus Acta Probat
If you use one of the syslog implementations for Windows, it will have the advantage that in a heterogeneous environment, you can still use the upstream syslog tools...

Quote:Original post by Katie
If you use one of the syslog implementations for Windows, it will have the advantage that in a heterogeneous environment, you can still use the upstream syslog tools...



I like this idea but what are the downsides of going that route?

I downloaded something called Kiwi Syslog Server and installed it as a service. I then tried searching for *syslog*.h but didn't find any files like that. Backing up, perhaps someone could recommend a Windows syslog implementation that they like.
I enjoyed using the blah logging library. Just a .hpp/.cpp, as I recall, and under the Boost software license, which means you can do whatever you want to with it.
"what are the downsides of going that route?"

UNIX style logging... It sort of depends what the existing infrastructure is like. Syslog also isn't the nicest system and it operates as datagrams so on congested networks it won't reliably report things. If it's what's already used, however, then the admins almost certainly have a ton of infrastructure set up to handle it.

As for actually implementing it, it's not a complex protocol.

You just send a packet to localhost port 154. The format of the packet is fairly simple -- http://www.ietf.org/rfc/rfc3164.txt

You can probably assemble it using just a sprintf and then send it as a datagram. And that's it. One of the points is that the application's complexity is minimal and all the work gets done inside the local daemon - Kiwi is one of the popular ones.

Yeah, so that's pretty much all syslog does[1]. Sanity check the inputs, sprintf everything into a buffer (complicated by having to do a lot of the work just to handle a special %m sequence), possibly opens the daemon connection by trying a couple of different ways and then sends it to the log daemon, stderr and the console as appropriate and available.


[1] Love open source.

This topic is closed to new replies.

Advertisement