I am working on a project in C under a Linux environment and I’m looking for an efficient way to add errors to a log file.
I tried to use Syslog with the following initialization:
setlogmask(LOG_UPTO(7));
openlog(name, LOG_CONS | LOG_NDELAY | LOG_PID, LOG_USER);
But it seems that it works too slow. I need it to work very fast..
Can someone help with that? Maybe the syslog is not the right approach.
You can write a custom light weight logger or may 3rd party open source one…
For example 3rd part C++ logger [ http://logging.apache.org/log4cxx/%5D
And Here is simple [buggy] custom logger [ From book C++ Timesaving Techniques For Dummies ]
Usage :
Warning: This is “toy” logger with some bugs to just give you some idea about custom logger…Do not use directly in real applications..