How to implement a journal?

Am I finding a way to implement a log mechanism that multiple processes write their behavior (mainly for errors and process flow) using C with Linux?

Just open the file to be used for multiprocessing and let fprintf () handle it? Any clever way to implement a parameter / mechanism that controls the log level like error / detail / high or something like that?

Would it be better if you could reference an easy source for this?



source to share

3 answers

Use syslog

this standard (POSIX) logging solution.



In other languages, log4c is very popular (log4j, log4net). It has a lot of features that are easy to bake, and since it's so common, other developers who work on your code will be familiar with it.



Using fprintf is ok, however I'm not sure if fprintf is thread safe unless using a blocking mechanism to block the fprintf call for multiple concurrent accesses.



All Articles