StringMapMessage offers similar functionality. That's the concept I was 
looking for, thanks

    On Tuesday, September 21, 2021, 03:12:16 AM EDT, Volkan Yazıcı 
<volkan.yaz...@gmail.com> wrote:  
 
 What advantage(s) does it provide compared to simply logging a
`MapMessage`? Consider the following:

StringMapMessage message = new StringMapMessage();
message.put("Kind", "engine start");
message.put("Instant", "2016-09-28T23:28:51.224Z");
message.put("NextScheduledInstant", "2016-09-29T23:28:51.224Z");
logger.atWarn().log(message);

You might argue that constructing a `MapMessage` and passing it to
`Logger#log()` is not very convenient. That I agree with. But then let's
improve the `Logger` API instead.

On Tue, Sep 21, 2021 at 3:24 AM Ron Grabowski
<rongrabow...@yahoo.com.invalid> wrote:

> Any thoughts if the concept of a message template would add value to JSON
> Template Layout? Heavily inspired by Serilog:
>
> https://ikeptwalking.com/structured-logging-using-serilog/https://blog.rsuter.com/logging-with-ilogger-recommendations-and-best-practices/https://benfoster.io/blog/serilog-best-practices/
> Two examples playing around with syntax:
> "message" : "Engine Started at 09/28/2016 23:28:51, restart scheduled for
> 09/29/2016 23:28:51","message_template" : "Engine started at {TimeOfStart},
> restart scheduled for {TimeOfRestart}","message_template_hash" :
> "152d8ea","message_fields" : {  "TimeOfStart" :
> "2016-09-28T23:28:51.224+10:00",  "TimeOfStart" :
> "2016-09-29T23:28:51.224+10:00"}
> "message.template" : "Engine started at {}, restart scheduled for
> {}","message.template.hash" : "152d8ea","message.args" : [
> "2016-09-28T23:28:51.2247447+10:00",  "2016-09-29T23:28:51.2247447+10:00"]
> In the second example message is omitted on purpose because we want the
> structured version. When looking for occurrences of the same event you
> could search for a short value without having to use wildcards or regex.
> Hash seems complex, it could be replaced by a marker at the call site.
>
>
  

Reply via email to