More robust log file redirection.

I.e. directly redirect System.err stream to a file. 
Instead of trying to get a hodge-podge of different java logging systems to all  send output to the same file.
This commit is contained in:
Kris De Volder
2018-01-31 14:47:40 -08:00
parent 4969e4743d
commit 67e5131718
2 changed files with 8 additions and 8 deletions

View File

@@ -11,19 +11,19 @@
package org.springframework.ide.vscode.commons.util;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintStream;
public class LogRedirect {
public static void redirectToFile(String name) throws IOException {
File logfile = null;
if (System.getProperty("org.slf4j.simpleLogger.logFile") == null) {
logfile = File.createTempFile(name, ".log");
System.setProperty("org.slf4j.simpleLogger.logFile", logfile.toString());
} else {
logfile = new File(System.getProperty("org.slf4j.simpleLogger.logFile"));
String logfilePath = System.getProperty("sts.log.file");
if (StringUtil.hasText(logfilePath)) {
File logfile = new File(logfilePath);
System.err.println("Redirecting log output to: "+logfile);
System.setErr(new PrintStream(new FileOutputStream(logfile, false)));
}
System.err.println("Redirecting log output to: "+logfile);
}
}

View File

@@ -109,7 +109,7 @@ export function activate(options: ActivatorOptions, context: VSCode.ExtensionCon
const args = [
'-Dserver.port=' + port,
'-Dsts.lsp.client=vscode',
'-Dorg.slf4j.simpleLogger.logFile=' + logfile
'-Dsts.log.file=' + logfile
];
if (options.classpath) {
const classpath = options.classpath(context, version);