mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-24 05:38:11 +00:00
main/logger: Add log formatters and JSON structured logs
When Asterisk is part of a larger distributed system, log files are often
gathered using tools (such as logstash) that prefer to consume information
and have it rendered using other tools (such as Kibana) that prefer a
structured format, e.g., JSON. This patch adds support for JSON formatted
logs by adding support for an optional log format specifier in Asterisk's
logging subsystem. By adding a format specifier of '[json]':
full => [json]debug,verbose,notice,warning,error
Log messages will be output to the 'full' channel in the following
format:
{
"hostname": Hostname or name specified in asterisk.conf
"timestamp": Date/Time
"identifiers": {
"lwp": Thread ID,
"callid": Call Identifier
}
"logmsg": {
"location": {
"filename": Name of the file that generated the log statement
"function": Function that generated the log statement
"line": Line number that called the logging function
}
"level": Log level, e.g., DEBUG, VERBOSE, etc.
"message": Actual text of the log message
}
}
ASTERISK-25425 #close
Change-Id: I8649bfedf3fb7bf3138008cc11565553209cc238
This commit is contained in:
@@ -80,7 +80,35 @@
|
||||
;
|
||||
[logfiles]
|
||||
;
|
||||
; Format is "filename" and then "levels" of debugging to be included:
|
||||
; Format is:
|
||||
;
|
||||
; logger_name => [formatter]levels
|
||||
;
|
||||
; The name of the logger dictates not only the name of the logging
|
||||
; channel, but also its type. Valid types are:
|
||||
; - 'console' - The root console of Asterisk
|
||||
; - 'syslog' - Linux syslog, with facilities specified afterwards with
|
||||
; a period delimiter, e.g., 'syslog.local0'
|
||||
; - 'filename' - The name of the log file to create. This is the default
|
||||
; for log channels.
|
||||
;
|
||||
; Filenames can either be relative to the standard Asterisk log directory
|
||||
; (see 'astlogdir' in asterisk.conf), or absolute paths that begin with
|
||||
; '/'.
|
||||
;
|
||||
; An optional formatter can be specified prior to the log levels sent
|
||||
; to the log channel. The formatter is defined immediately preceeding the
|
||||
; levels, and is enclosed in square brackets. Valid formatters are:
|
||||
; - [default] - The default formatter, this outputs log messages using a
|
||||
; human readable format.
|
||||
; - [json] - Log the output in JSON. Note that JSON formatted log entries,
|
||||
; if specified for a logger type of 'console', will be formatted
|
||||
; per the 'default' formatter for log messages of type VERBOSE.
|
||||
; This is due to the remote consoles intepreting verbosity
|
||||
; outside of the logging subsystem.
|
||||
;
|
||||
; Log levels include the following, and are specified in a comma delineated
|
||||
; list:
|
||||
; debug
|
||||
; notice
|
||||
; warning
|
||||
@@ -90,12 +118,6 @@
|
||||
; fax
|
||||
; security
|
||||
;
|
||||
; Special filename "console" represents the root console
|
||||
;
|
||||
; Filenames can either be relative to the standard Asterisk log directory
|
||||
; (see 'astlogdir' in asterisk.conf), or absolute paths that begin with
|
||||
; '/'.
|
||||
;
|
||||
; Verbose takes an optional argument, in the form of an integer level.
|
||||
; Verbose messages with higher levels will not be logged to the file. If
|
||||
; the verbose level is not specified, it will log verbose messages following
|
||||
@@ -127,7 +149,9 @@ console => notice,warning,error
|
||||
;console => notice,warning,error,debug
|
||||
messages => notice,warning,error
|
||||
;full => notice,warning,error,debug,verbose,dtmf,fax
|
||||
|
||||
;
|
||||
;full-json => [json]debug,verbose,notice,warning,error,dtmf,fax
|
||||
;
|
||||
;syslog keyword : This special keyword logs to syslog facility
|
||||
;
|
||||
;syslog.local0 => notice,warning,error
|
||||
|
||||
Reference in New Issue
Block a user