Search in sources :

Example 11 with ThrowableInformation

use of org.apache.log4j.spi.ThrowableInformation in project lucene-solr by apache.

the class Log4jWatcher method toSolrDocument.

@Override
public SolrDocument toSolrDocument(LoggingEvent event) {
    SolrDocument doc = new SolrDocument();
    doc.setField("time", new Date(event.getTimeStamp()));
    doc.setField("level", event.getLevel().toString());
    doc.setField("logger", event.getLogger().getName());
    doc.setField("message", event.getRenderedMessage());
    ThrowableInformation t = event.getThrowableInformation();
    if (t != null) {
        doc.setField("trace", Throwables.getStackTraceAsString(t.getThrowable()));
    }
    // Will be null if not present
    doc.setField("core", event.getMDC(ZkStateReader.CORE_NAME_PROP));
    doc.setField("collection", event.getMDC(ZkStateReader.COLLECTION_PROP));
    doc.setField("replica", event.getMDC(ZkStateReader.REPLICA_PROP));
    doc.setField("shard", event.getMDC(ZkStateReader.SHARD_ID_PROP));
    return doc;
}
Also used : SolrDocument(org.apache.solr.common.SolrDocument) ThrowableInformation(org.apache.log4j.spi.ThrowableInformation) Date(java.util.Date)

Aggregations

ThrowableInformation (org.apache.log4j.spi.ThrowableInformation)11 IOException (java.io.IOException)2 StringWriter (java.io.StringWriter)2 NoRouteToHostException (java.net.NoRouteToHostException)2 LocationInfo (org.apache.log4j.spi.LocationInfo)2 Test (org.junit.Test)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ContainerNode (com.fasterxml.jackson.databind.node.ContainerNode)1 IdeaApplication (com.intellij.idea.IdeaApplication)1 Application (com.intellij.openapi.application.Application)1 ErrorLogger (com.intellij.openapi.diagnostic.ErrorLogger)1 IdeaLoggingEvent (com.intellij.openapi.diagnostic.IdeaLoggingEvent)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 LoggingEvent (org.apache.log4j.spi.LoggingEvent)1 ZkController (org.apache.solr.cloud.ZkController)1 SolrDocument (org.apache.solr.common.SolrDocument)1 SolrCore (org.apache.solr.core.SolrCore)1 SolrQueryRequest (org.apache.solr.request.SolrQueryRequest)1