You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@solr.apache.org by Morten Bøgeskov <mb...@dbc.dk.INVALID> on 2024/04/08 08:35:14 UTC

JSON logging and collection/shard/replica

Hello.

This might not be the right place to ask this (maybe log4j?), however my question goes:

I would like a JSON log format. I'm looking at https://logging.apache.org/log4j/2.x/manual/json-template-layout.html And can't figure out how to access the fields referred in:
        <Pattern>
          %maxLen{%d{yyyy-MM-dd HH:mm:ss.SSS} %-5p (%t) [%notEmpty{c:%X{collection}}%notEmpty{ s:%X{shard}}%notEmpty{ r:%X{replica}}%notEmpty{ x:%X{core}}%notEmpty{ t:%X{trace_id}}] %c{1.} %m%notEmpty{ =>%ex{short}}}{10240}%n
        </Pattern>

as collection/shard/replica. When I use resolver "mdc" (As I understand X to be from https://logging.apache.org/log4j/2.x/manual/layouts.html#PatternLayout) in my JSON template I get:
{"core":"corepo","rid":"null-5","trace_id":"null-5"}
Any thoughts on how to log those?

It would be awfully useful to know, if one replica is significantly slower that the others in same shard (to monitor disk degradation).

\Morten

Re: JSON logging and collection/shard/replica

Posted by Morten Bøgeskov <mb...@dbc.dk.INVALID>.
Sorry for the noise....

I've been running our (inhouse) docker images, with the variable ZKSRING instead of ZKSTRING for two days now. Well, that was a complete waste of everybodys time.

Yes, everything is as expected in the JSON log.

The hint, to locate my mistake, was much appreciated.

\Morten
________________________________
From: Chris Hostetter <ho...@fucit.org>
Sent: Monday, April 8, 2024 20:27
To: users@solr.apache.org <us...@solr.apache.org>
Subject: Re: JSON logging and collection/shard/replica

[You don't often get email from hossman_lucene@fucit.org. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]

If you are getting any values from the MDC resolver, then you have the MDC
resolver configured correctly.

You're only going to get MDC values like collection/shard/replica if those
are defined for the thread that logged the message you are looking at.

In the specific example you posted...

: {"core":"corepo","rid":"null-5","trace_id":"null-5"}

...thta "core" name does not look like a a core name that solr would have
created in solr cloud mode -- it looks like maybe you are just running a
trivial example solr instance where you manually created a core? ... in
which case there is no collection/shard/replica data to include in the MDC
for that request.



-Hoss
http://www.lucidworks.com/

Re: JSON logging and collection/shard/replica

Posted by Chris Hostetter <ho...@fucit.org>.
If you are getting any values from the MDC resolver, then you have the MDC 
resolver configured correctly.

You're only going to get MDC values like collection/shard/replica if those 
are defined for the thread that logged the message you are looking at.

In the specific example you posted...

: {"core":"corepo","rid":"null-5","trace_id":"null-5"}

...thta "core" name does not look like a a core name that solr would have 
created in solr cloud mode -- it looks like maybe you are just running a 
trivial example solr instance where you manually created a core? ... in 
which case there is no collection/shard/replica data to include in the MDC 
for that request.



-Hoss
http://www.lucidworks.com/