[Home]

Summary:ASTERISK-25425: logger: Add JSON structured logging
Reporter:Matt Jordan (mjordan)Labels:
Date Opened:2015-09-27 21:54:46Date Closed:2015-09-29 09:29:17
Priority:MajorRegression?
Status:Closed/CompleteComponents:Core/Logging
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:
Description: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}
Comments:By: Deepak Singh Rawat (dsr) 2016-01-18 04:10:52.054-0600

Hi Matt, is there a target release for this feature?

By: Joshua C. Colp (jcolp) 2016-01-18 05:50:53.411-0600

This was placed into master only, so it will be available in Asterisk 14.

By: Chad McElligott (cmcelligott) 2016-08-23 20:29:46.282-0500

super stoked about this feature