diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/EquinoxLogWriter.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/EquinoxLogWriter.java index bfd7b4068e..cd5ba36749 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/EquinoxLogWriter.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/EquinoxLogWriter.java @@ -85,6 +85,9 @@ class EquinoxLogWriter implements SynchronousLogListener, LogFilter { /** The system property used to specify command line args should be omitted from the log */ private static final String PROP_LOG_INCLUDE_COMMAND_LINE = "eclipse.log.include.commandline"; //$NON-NLS-1$ + /** The system property used to specify the the log file writer should be closed eagerly */ + private static final String PROP_CLOSE_LOG_FILE_EAGERLY = "eclipse.log.closeFile.eagerClose"; //$NON-NLS-1$ + /** Indicates if the console messages should be printed to the console (System.out) */ private boolean consoleLog = false; /** Indicates if the next log message is part of a new session */ @@ -112,6 +115,15 @@ class EquinoxLogWriter implements SynchronousLogListener, LogFilter { private LoggerAdmin loggerAdmin = null; + /** + * Controls whether the log file should be closed eagerly upon every log + * invocation. + * + * Can be controlled by property + * {@link EquinoxLogWriter#PROP_CLOSE_LOG_FILE_EAGERLY}. + */ + private boolean closeLogFileEagerly = false; + /** * Constructs an EclipseLog which uses the specified File to log messages to * @param outFile a file to log messages to @@ -322,6 +334,10 @@ private synchronized void log(FrameworkLogEntry logEntry) { // ensure that the error stream writer is closed closeFile(); } + } finally { + if (closeLogFileEagerly) { + closeFile(); + } } } @@ -683,6 +699,13 @@ else if (newLogLevel.equals("INFO")) //$NON-NLS-1$ includeCommandLine = "true".equals(environmentInfo.getConfiguration(PROP_LOG_INCLUDE_COMMAND_LINE, "true")); //$NON-NLS-1$//$NON-NLS-2$ applyLogLevel(); + + String newCloseLogFileEagerlyValue = environmentInfo.getConfiguration(PROP_CLOSE_LOG_FILE_EAGERLY); + if (newCloseLogFileEagerlyValue != null) { + if (Boolean.valueOf(newCloseLogFileEagerlyValue) == Boolean.TRUE) { + closeLogFileEagerly = true; + } + } } void applyLogLevel() {