How to Print Output for Debugging Solr

Michael A. Alcorn
1 min readMar 31, 2018

Printing output is a crucial part of debugging code. Doing so is easy in Solr, but it wasn’t at all obvious to me, so I’ve put the steps down here. The first thing you need to do is import some logging libraries.

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.lang.invoke.MethodHandles;

Next, put the following line below your class declaration.

private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());

Now, whenever you want to log something to the Solr Admin Logging window, just use the following:

log.info("Some message.");

More information on logging in Solr can be found here.

--

--