Adjusting Log4j properties to generate targeted logs

By default, nearly everything that gets logged from solr ends up in the logs/solr.log file.  If one wishes to generate more specific logs, such as a log that contains only information about solr updates, or queries that were processed, here's one way to accomplish that using log4j settings.

Attached is a customized file, and some associated log files created from it.  These are based on the standard package of solr-4.10.4.  The notable changes are discussed below.

The general technique is to identify the Solr class that logs the information that you want, and then configure log4j to write those events to a separate file.  There's a couple of ways to identify the class you're interested in.

  • Look through the current solr.log for the entries that you wish to have sent to a separate file.  The class is mentioned in the log entry:

INFO - 2015-06-05 14:01:13.631; org.apache.solr.update.processor.LogUpdateProcessor; [collection1] webapp=/solr path=/update params={wt=json} {add=[testDocument2 (1503147194942750720)]} 0 43

  • The Solr Admin UI has a Logging/Level page that displays the whole tree that participates in the log4j process. (http://SERVER:PORT/solr/#/~logging/level) Hovering the mouse over the class should popup the full class name.

Once you know the class name, modify the log4j properties file.  At the minimum, you'll have to associate the class to a logger, define the type of logger to use, and assign a filename to the log.  See the attached example file for a more complete listing.

# Logger for updates, Updates

Have more questions? Submit a request


Please sign in to leave a comment.
Powered by Zendesk