unbit / uwsgi

uWSGI application server container
http://projects.unbit.it/uwsgi
Other
3.46k stars 691 forks source link

Facility configuration in rsyslog plugin #1239

Open amyangfei opened 8 years ago

amyangfei commented 8 years ago

When using rsyslog plugin I found the document(logging-to-remote-syslog) tells

you may pass an optional ID to send as the “facility” parameter for the log entry"

I found the syslog plugin supports the option facility name such as:

--logger rsyslog:12.34.56.78:12345,uwsgi1234,local2

The facility name will be translated to its corresponding int value defined in syslog.h. But the rsyslog plugin doesn't support this, an integer value must be used to represent the facility.

Besides as we know the syslog protocol starts with <priority>:msg , priority = facility | level. If we pass an integer value we can config an arbitrary priority for rsyslog plugin, while the syslog plugin uses the following hard code for log level, and the rsyslog plugin uses 29 (LOG_DAEMON | LOG_NOTICE) as default priority if priority integer not provided.

#ifdef __APPLE__
    syslog(LOG_NOTICE, "%.*s", (int) len, message);
#else
    syslog(LOG_INFO, "%.*s", (int) len, message);
#endif

Maybe rsyslog plugin could support facility configuration with a human-readable name the same as syslog plugin, while preserving the mechanism that using an integer to represent priority.

salah93 commented 4 years ago

found this for anyone curious https://success.trendmicro.com/solution/TP000086250-What-are-Syslog-Facilities-and-Levels

The priority value is calculated using the formula (Priority = Facility * 8 + Level). For example, a kernel message (Facility=0) with a Severity of Emergency (Severity=0) would have a Priority value of 0. Also, a "local use 4" message (Facility=20) with a Severity of Notice (Severity=5) would have a Priority value of 165.