mirror of
https://github.com/rsyslog/rsyslog.git
synced 2025-12-19 02:10:42 +01:00
make rsyslog log by default to syslog()
this enables us to put error messages to systemd journal; which is especially useful as most distros by default throw away rsyslog error messages.
This commit is contained in:
parent
7c52a118c9
commit
99ac6d5143
@ -73,9 +73,9 @@ stdlog_channel_t stdlog_hdl = NULL; /* handle to be used for stdlog */
|
||||
#endif
|
||||
|
||||
static struct cnfobj *mainqCnfObj = NULL;/* main queue object, to be used later in startup sequence */
|
||||
int bProcessInternalMessages = 1; /* Should rsyslog itself process internal messages?
|
||||
int bProcessInternalMessages = 0; /* Should rsyslog itself process internal messages?
|
||||
* 1 - yes
|
||||
* 0 - send them to libstdlog (e.g. to push to journal)
|
||||
* 0 - send them to libstdlog (e.g. to push to journal) or syslog()
|
||||
*/
|
||||
static uchar *pszWorkDir = NULL;
|
||||
#ifdef HAVE_LIBLOGGING_STDLOG
|
||||
@ -968,21 +968,12 @@ glblProcessCnf(struct cnfobj *o)
|
||||
continue;
|
||||
if(!strcmp(paramblk.descr[i].name, "processinternalmessages")) {
|
||||
bProcessInternalMessages = (int) cnfparamvals[i].val.d.n;
|
||||
#ifndef HAVE_LIBLOGGING_STDLOG
|
||||
if(bProcessInternalMessages != 1) {
|
||||
bProcessInternalMessages = 1;
|
||||
errmsg.LogError(0, RS_RET_ERR, "rsyslog wasn't "
|
||||
"compiled with liblogging-stdlog support. "
|
||||
"The 'ProcessInternalMessages' parameter "
|
||||
"is ignored.\n");
|
||||
}
|
||||
#endif
|
||||
} else if(!strcmp(paramblk.descr[i].name, "stdlog.channelspec")) {
|
||||
#ifndef HAVE_LIBLOGGING_STDLOG
|
||||
errmsg.LogError(0, RS_RET_ERR, "rsyslog wasn't "
|
||||
"compiled with liblogging-stdlog support. "
|
||||
"The 'stdlog.channelspec' parameter "
|
||||
"is ignored.\n");
|
||||
"is ignored. Note: the syslog API is used instead.\n");
|
||||
#else
|
||||
stdlog_chanspec = (uchar*)
|
||||
es_str2cstr(cnfparamvals[i].val.d.estr, NULL);
|
||||
|
||||
@ -93,6 +93,7 @@ case $1 in
|
||||
if [ -e IN_AUTO_DEBUG ]; then
|
||||
export valgrind="valgrind --malloc-fill=ff --free-fill=fe --log-fd=1"
|
||||
fi
|
||||
export RSYSLOG_DFLT_LOG_INTERNAL=1 # testbench needs internal messages logged internally!
|
||||
;;
|
||||
'exit') # cleanup
|
||||
# detect any left-over hanging instance
|
||||
|
||||
@ -25,9 +25,12 @@
|
||||
#include "rsyslog.h"
|
||||
|
||||
#include <signal.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/wait.h>
|
||||
#ifdef HAVE_LIBLOGGING_STDLOG
|
||||
# include <liblogging/stdlog.h>
|
||||
#else
|
||||
# include <syslog.h>
|
||||
#endif
|
||||
#ifdef OS_SOLARIS
|
||||
# include <errno.h>
|
||||
@ -786,10 +789,12 @@ logmsgInternal(int iErr, const syslog_pri_t pri, const uchar *const msg, int fla
|
||||
CHKiRet(logmsgInternalSelf(iErr, pri, lenMsg,
|
||||
(bufModMsg == NULL) ? (char*)msg : bufModMsg,
|
||||
flags));
|
||||
#ifdef HAVE_LIBLOGGING_STDLOG
|
||||
} else {
|
||||
#ifdef HAVE_LIBLOGGING_STDLOG
|
||||
stdlog_log(stdlog_hdl, pri2sev(pri), "%s",
|
||||
(bufModMsg == NULL) ? (char*)msg : bufModMsg);
|
||||
#else
|
||||
syslog(pri, "%s", msg);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -1647,6 +1652,9 @@ main(int argc, char **argv)
|
||||
{
|
||||
/* use faster hash function inside json lib */
|
||||
json_global_set_string_hash(JSON_C_STR_HASH_PERLLIKE);
|
||||
const char *const log_dflt = getenv("RSYSLOG_DFLT_LOG_INTERNAL");
|
||||
if(log_dflt != NULL && !strcmp(log_dflt, "1"))
|
||||
bProcessInternalMessages = 1;
|
||||
dbgClassInit();
|
||||
initAll(argc, argv);
|
||||
sd_notify(0, "READY=1");
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user