SOLR-3157: improve logging, restore legacy logging if not testing

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1294911 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Yonik Seeley 2012-02-29 00:12:44 +00:00
parent f75eae6217
commit 2b055c2195
5 changed files with 25 additions and 22 deletions

View File

@ -186,8 +186,8 @@ sb.append("(group_name=").append(tg.getName()).append(")");
if (info != null) {
sb.append(' ').append(info.shortId); // core
} else if (zkController != null) {
// if we don't have info about the core, then at least try to do core container
}
if (zkController != null) {
sb.append(" P").append(zkController.getHostPort());
}

View File

@ -1514,6 +1514,9 @@ public final class SolrCore implements SolrInfoMBean {
}
}
/** @lucene.internal use the more consiste testLoggingFormat for tests... for use with SolrLogFormatter */
public static boolean isTestLoggingFormat;
public void execute(SolrRequestHandler handler, SolrQueryRequest req, SolrQueryResponse rsp) {
if (handler==null) {
@ -1533,12 +1536,12 @@ public final class SolrCore implements SolrInfoMBean {
// for back compat, we set these now just in case other code
// are expecting them during handleRequest
// multiple webaps are no longer best practise
// toLog.add("webapp", req.getContext().get("webapp"));
if (!isTestLoggingFormat) {
toLog.add("webapp", req.getContext().get("webapp"));
}
toLog.add(isTestLoggingFormat ? null : "path", req.getContext().get("path"));
toLog.add(isTestLoggingFormat ? null : "params", "{" + req.getParamString() + "}");
toLog.add("path", req.getContext().get("path"));
toLog.add("params", "{" + req.getParamString() + "}");
handler.handleRequest(req,rsp);
setResponseHeaderValues(handler,req,rsp);
@ -1547,11 +1550,10 @@ public final class SolrCore implements SolrInfoMBean {
for (int i=0; i<toLog.size(); i++) {
String name = toLog.getName(i);
Object val = toLog.getVal(i);
if ("path"==name || "params"==name) { //equals OK here
sb.append(val).append(' ');
} else {
sb.append(name).append('=').append(val).append(' ');
if (name != null) {
sb.append(name).append('=');
}
sb.append(val).append(' ');
}
log.info(sb.toString());

View File

@ -913,11 +913,10 @@ public class UpdateLog implements PluginInfoInitialized {
private RecoveryInfo recoveryInfo;
public static Logger loglog = LoggerFactory.getLogger(LogReplayer.class);
// TODO: do we let the log replayer run across core reloads?
class LogReplayer implements Runnable {
private Logger loglog = log; // set to something different?
TransactionLog translog;
TransactionLog.LogReader tlogReader;

View File

@ -61,7 +61,7 @@ public class LogUpdateProcessorFactory extends UpdateRequestProcessorFactory {
}
class LogUpdateProcessor extends UpdateRequestProcessor {
public final static Logger log = LoggerFactory.getLogger(UpdateRequestProcessor.class);
public final static Logger log = LoggerFactory.getLogger(LogUpdateProcessor.class);
private final SolrQueryRequest req;
private final SolrQueryResponse rsp;
@ -182,15 +182,16 @@ class LogUpdateProcessor extends UpdateRequestProcessor {
NamedList<Object> stdLog = rsp.getToLog();
StringBuilder sb = new StringBuilder();
for (int i=0; i<stdLog.size(); i++) {
String name = stdLog.getName(i);
Object val = stdLog.getVal(i);
if ("path"==name || "params"==name) { //equals OK here
sb.append(val).append(' ');
} else {
sb.append(name).append('=').append(val).append(' ');
for (int i=0; i<toLog.size(); i++) {
String name = toLog.getName(i);
Object val = toLog.getVal(i);
if (name != null) {
sb.append(name).append('=');
}
sb.append(val).append(' ');
}
stdLog.clear(); // make it so SolrCore.exec won't log this again
// if id lists were truncated, show how many more there were
@ -202,7 +203,7 @@ class LogUpdateProcessor extends UpdateRequestProcessor {
}
long elapsed = rsp.getEndTime() - req.getStartTime();
sb.append(toLog).append(" 0 ").append(elapsed);
sb.append(" 0 ").append(elapsed);
log.info(sb.toString());
}
}

View File

@ -99,6 +99,7 @@ public abstract class SolrTestCaseJ4 extends LuceneTestCase {
public static void setupLogging() {
SolrCore.isTestLoggingFormat = true;
boolean register = false;
Handler[] handlers = java.util.logging.Logger.getLogger("").getHandlers();
ConsoleHandler consoleHandler = null;