You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Joan <jo...@gmail.com> on 2011/09/15 13:50:35 UTC

How to write core's name in log

Hi,

I have multiple core in Solr and I want to write core name in log through to
lo4j.

I've found in SolrException a method called log(Logger log, Throwable e) but
when It try to build a Exception it haven't core's name.

The Exception is built in toStr() method in SolrException class, so I want
to write core's name in the message of Exception.

I'm thinking to add MDC variable, this will be name of core. Finally I'll
use it in log4j configuration like this in ConversionPattern %X{core}

The idea is that when Solr received a request I'll add this new variable
"name of core".

But I don't know if it's a good idea or not.

or Do you already exists any solution for add name of core in log?

Thanks

Joan

Re: How to write core's name in log

Posted by Pulkit Singhal <pu...@gmail.com>.
Not sure if this is a good lead for you but when I run out-of-the-box
multi-core example-DIH instance of Solr, I often see core name thrown
about in the logs. Perhaps you can look there?

On Thu, Sep 15, 2011 at 6:50 AM, Joan <jo...@gmail.com> wrote:
> Hi,
>
> I have multiple core in Solr and I want to write core name in log through to
> lo4j.
>
> I've found in SolrException a method called log(Logger log, Throwable e) but
> when It try to build a Exception it haven't core's name.
>
> The Exception is built in toStr() method in SolrException class, so I want
> to write core's name in the message of Exception.
>
> I'm thinking to add MDC variable, this will be name of core. Finally I'll
> use it in log4j configuration like this in ConversionPattern %X{core}
>
> The idea is that when Solr received a request I'll add this new variable
> "name of core".
>
> But I don't know if it's a good idea or not.
>
> or Do you already exists any solution for add name of core in log?
>
> Thanks
>
> Joan
>

Re: How to write core's name in log

Posted by Chris Hostetter <ho...@fucit.org>.
: I'm thinking to add MDC variable, this will be name of core. Finally I'll
: use it in log4j configuration like this in ConversionPattern %X{core}
: 
: The idea is that when Solr received a request I'll add this new variable
: "name of core".
: 
: But I don't know if it's a good idea or not.
: 
: or Do you already exists any solution for add name of core in log?

Assuming you definitively want to use log4j, then i think you are on the 
right track -- you could certainly patch SolrDispatchFilter to add the 
name of the selected core as an MDC.

in general, the name of the current core isn't something that every code 
path knows about, so something like this is probably the only option.


-Hoss