Linux registrar guidelines

I am creating a C ++ Linux application and I need to log it. What are the existing Linux logging capabilities? What would you recommend?

+3
source share
4 answers

What about log4cxx ?

+3
source

Historical is syslog (3). From C:

#include <syslog.h>
openlog("myprogram", LOG_PID, LOG_LOCAL0);
syslog(LOG_INFO, "data %d %s", 3, "example");

From Perl:

use Sys::Syslog;
openlog "myprogram", "pid", "local0";
syslog 'info', 'data %d %s', 3, 'example';

From the shell:

logger -p local0.info -t myprogram -- data 3 example

The syslogd daemon can be configured to place log files in different places (files, tty, other machines) depending on the object (here LOG_LOCAL0) and priority (here LOG_INFO)

+10
source

, , Linux?

+1

I recommend you try c-log, a fast, stable and thread-safe logger for C / C ++, https://github.com/0xmalloc/c-log .

0
source

Source: https://habr.com/ru/post/1703278/


All Articles