I'm currently using the not so sophisticated printf
method of logging; and I'm wondering whether to use something like "log4c
" "zlog
" or "syslog
" to better manage ongoing debug/informational output. I'm not asking for a "best" library for the task; but for help on choosing when the added complexity and dependency of a logging library is outweighed by the neatness and organization provided. What level of complexity of a project merits a special purpose library?
Asked
Active
Viewed 443 times
1

Waqar
- 8,558
- 4
- 35
- 43

justinzane
- 1,897
- 1
- 26
- 38
-
I'd recommend using a library as soon as you are thinking about needing anything more sophisticated than `printf()` or `fprintf(stderr, ...)`. It needn't necessarily be a very complex library, but having something to use that allows you compile-time and run-time controls over what diagnostics are available and appear is very useful in 'bigger' programs (for an ill-defined value of 'bigger' -- I'd suggest maybe 'more than 4 main, non-library source files'). – Jonathan Leffler Jun 09 '15 at 20:47
1 Answers
0
When debugging, use fprintf(stderr, .... );
When logging for long term use, suggest syslog() because:
- the syslog contents are automatically archived each day.
- the syslog is where most users go to help trace project activity.
- the syslog records are date/time stamped.
- syslog is very flexible on the data contents portion of the records.

Jonathan Leffler
- 730,956
- 141
- 904
- 1,278

user3629249
- 16,402
- 1
- 16
- 17