Show stacktrace of startup exception
Whether or not the stacktrace is displayed is controlled by bootstrap log level setting, so that bootstrap: DEBUG displays the stack trace on output, like it does on log Closes #5102
This commit is contained in:
parent
4d6eb369a3
commit
3ae02b0b60
|
@ -23,6 +23,9 @@ import org.elasticsearch.common.logging.ESLogger;
|
|||
import org.elasticsearch.common.logging.Loggers;
|
||||
import org.elasticsearch.rest.RestStatus;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
@ -110,4 +113,11 @@ public final class ExceptionsHelper {
|
|||
return t.getClass().getSimpleName() + "[" + t.getMessage() + "]";
|
||||
}
|
||||
}
|
||||
|
||||
public static String stackTrace(Throwable e) {
|
||||
StringWriter stackTraceStringWriter = new StringWriter();
|
||||
PrintWriter printWriter = new PrintWriter(stackTraceStringWriter);
|
||||
e.printStackTrace(printWriter);
|
||||
return stackTraceStringWriter.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -274,6 +274,9 @@ public class Bootstrap {
|
|||
} else {
|
||||
errorMessage.append("- ").append(ExceptionsHelper.detailedMessage(e, true, 0));
|
||||
}
|
||||
if (Loggers.getLogger(Bootstrap.class).isDebugEnabled()) {
|
||||
errorMessage.append("\n").append(ExceptionsHelper.stackTrace(e));
|
||||
}
|
||||
return errorMessage.toString();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue