[logback-dev] [JIRA] (LOGBACK-1356) Have MessageConverter include any extra arguments

QOS.CH (JIRA) noreply-jira at qos.ch
Fri Dec 1 15:32:00 CET 2017


Eric Pabst created LOGBACK-1356:
-----------------------------------

             Summary: Have MessageConverter include any extra arguments
                 Key: LOGBACK-1356
                 URL: https://jira.qos.ch/browse/LOGBACK-1356
             Project: logback
          Issue Type: Improvement
          Components: logback-classic
    Affects Versions: 1.2.3
         Environment: All
            Reporter: Eric Pabst
            Assignee: Logback dev list


The purpose of logging to slf4j is to allow code to log information without worrying about which implementation and format will be used for actual logging.  In deployed environments, we prefer JSON logging using logstash to be consumed by Splunk, which handles JSON very nicely.  However, for local development and testing, we prefer text output via logback-classic.

We often want to log extra fields to show up in the JSON output such as 

{{\{ "timestamp": "2017...", "message": "Event X happened", "userName": "bob", "url": "http://..."}}}

To accomplish this, we use logstash's StructuredArgument to provide extra arguments to the Logger:

{{import static net.logstash.logback.argument.StructuredArguments.keyValue;}}
{{...}}
{{  LOGGER.info("Event X happened", keyValue("userName", "bob"), keyValue("url", "http://..."));}}

We don't want to include \{}'s in the message or else it would log the username and url both in the message and as separate JSON properties.

However, when binding to logback-classic, it is logged without these extra arguments:

{{INFO 2017... Event X happened}}

It would help immensely to include these extra arguments automatically if present:

INFO 2017... Event X happened username=bob url=http://... 



--
This message was sent by Atlassian JIRA
(v7.3.1#73012)


More information about the logback-dev mailing list