From 41b721baee31356f442b1fb3f198456a0dd3b2db Mon Sep 17 00:00:00 2001 From: "Bala.FA" Date: Tue, 14 May 2013 14:53:07 +0530 Subject: log: send current gf_log to syslog conditionally When compile time option GF_USE_SYSLOG is enabled (which is default), generated logs are sent to syslog with error code ERR_DEV. User can opt to use traditional log at run time by creating /var/log/glusterd/logger.conf file and restarting respective gluster services. Change-Id: I9837d0f99da1afc2189d7ecd214c4293ec53715a BUG: 928648 Signed-off-by: Bala.FA Reviewed-on: http://review.gluster.org/5002 Tested-by: Gluster Build System Reviewed-by: Vijay Bellur --- doc/logging.txt | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 doc/logging.txt (limited to 'doc') diff --git a/doc/logging.txt b/doc/logging.txt new file mode 100644 index 000000000..d1e568a31 --- /dev/null +++ b/doc/logging.txt @@ -0,0 +1,65 @@ + +New logging framework in glusterfs is targeted for end users like +customers, community members, testers etc. This aims to bring clear, +understandable logs called user logs whereas the current logging are +considered as developer logs. The new framework brings with following +features + +* Each message is logged with proper well defined error code and each + error code has well known error message. +* A logbook has defined error code and error messages. It helps to + keep track of possible causes and remedies +* Log are sent to syslog. The syslog application can be configured to + pass them to centralized logging system +* It brings + - Remove repeated log messages + - Send alerts to users on certain events + - Run a program on events + - Call home service on events + + +Log book: +========= +A log book is a JSON formatted file error-codes.json located in top +level of glusterfs source repository. At compile time, gen-headers.py +generates libglusterfs/src/gf-error-codes.h using the log book and +gf-error-codes.h.template file. libglusterfs/src/gf-error-codes.h +consists of header definitions and helper functions to get message by +code for given locale. Currently it has _gf_get_message() function +returns message for locale 'en'. + +New entry to log book is added like + +{ + "IO_ERROR": {"code": 2233, + "message": {"en": "I/O error occurred"}}, + "SETUP_ERROR": {"code": 2240, + "message": {"en": "Setup error"}}, +} + + +Logging: +======== +The framework provides two functions + +void gf_openlog (const char *ident, int option, int facility); +void gf_syslog (int error_code, int facility_priority, char *format, ...); + +Consumers need to call gf_openlog() prior to gf_syslog() like the way +traditional syslog function calls. error_code is mandatory when using +gf_syslog(). For example, + +gf_openlog (NULL, -1, -1); +gf_syslog (GF_ERR_DEV, LOG_ERR, "error reading configuration file"); + +The logs are sent in CEE format (http://cee.mitre.org/) to syslog. +Its targeted to rsyslog syslog server. + +This log framework can be disabled either at compile time or run time + +- for compile time by passing '--disable-syslog' to ./configure or + '--without syslog' to rpmbuild (or) +- for run time by having a file /var/log/glusterd/logger.conf and + restarting gluster services + +Currently all gluster logs are sent with error code GF_ERR_DEV. -- cgit