[asterisk-bugs] [JIRA] (ASTERISK-25425) logger: Add JSON structured logging

Matt Jordan (JIRA) noreply at issues.asterisk.org
Sun Sep 27 21:55:33 CDT 2015


Matt Jordan created ASTERISK-25425:
--------------------------------------

             Summary: logger: Add JSON structured logging
                 Key: ASTERISK-25425
                 URL: https://issues.asterisk.org/jira/browse/ASTERISK-25425
             Project: Asterisk
          Issue Type: New Feature
      Security Level: None
          Components: Core/Logging
            Reporter: Matt Jordan


When Asterisk is part of a larger, distributed system, common logging tools (such as the ELK stack - Elastic Search/Logstash/Kibana) like to consume information in structured formats. While a grok filter can be setup in logstash to reformat the Asterisk logs, this requires some additional tricky work on the part of the Asterisk user, and can be challenging in the presence of multi-line log statements.

The patch put up for review in conjunction with this issue adds JSON logging to the logging subsystem. Log channels can be set up with an optional format specifier, where the default format specifier ({{[default}}) produces log entries in the current human readable format. A json log channel can be set up as following:

{code}
full => [json]debug,verbose,notice,warning,error
{code}

Which will produce log statements similar to those shown below:
{noformat}
{"hostname":"mjordan-laptop","timestamp":"2015-09-27 21:44:36","identifiers":{"lwp":14414,"callid":""},"logmsg":{"location":{"filename":"file.c","function":"ast_format_def_unregister","line":181},"level":"VERBOSE","message":"Unregistered format sln32\n"}}
{"hostname":"mjordan-laptop","timestamp":"2015-09-27 21:44:36","identifiers":{"lwp":14414,"callid":""},"logmsg":{"location":{"filename":"file.c","function":"ast_format_def_unregister","line":181},"level":"VERBOSE","message":"Unregistered format sln44\n"}}
{"hostname":"mjordan-laptop","timestamp":"2015-09-27 21:44:36","identifiers":{"lwp":14414,"callid":""},"logmsg":{"location":{"filename":"file.c","function":"ast_format_def_unregister","line":181},"level":"VERBOSE","message":"Unregistered format sln48\n"}}
{"hostname":"mjordan-laptop","timestamp":"2015-09-27 21:44:36","identifiers":{"lwp":14414,"callid":""},"logmsg":{"location":{"filename":"file.c","function":"ast_format_def_unregister","line":181},"level":"VERBOSE","message":"Unregistered format sln96\n"}}
{"hostname":"mjordan-laptop","timestamp":"2015-09-27 21:44:36","identifiers":{"lwp":14414,"callid":""},"logmsg":{"location":{"filename":"file.c","function":"ast_format_def_unregister","line":181},"level":"VERBOSE","message":"Unregistered format sln192\n"}}
{"hostname":"mjordan-laptop","timestamp":"2015-09-27 21:44:36","identifiers":{"lwp":14414,"callid":""},"logmsg":{"location":{"filename":"loader.c","function":"ast_module_shutdown","line":636},"level":"VERBOSE","message":"Unloading format_siren14.so\n"}}
{noformat}



--
This message was sent by Atlassian JIRA
(v6.2#6252)



More information about the asterisk-bugs mailing list