Configured Java logging for Bazel
Previously the logger output was sent out to the console,
leading to garbage information in batch mode. Now, the log
are sent to a log file in the output base.
--
MOS_MIGRATED_REVID=102989990
diff --git a/src/main/cpp/blaze_startup_options.cc b/src/main/cpp/blaze_startup_options.cc
index 05d4d39..1a4ecb8 100644
--- a/src/main/cpp/blaze_startup_options.cc
+++ b/src/main/cpp/blaze_startup_options.cc
@@ -142,8 +142,23 @@
blaze_exit_code::ExitCode BlazeStartupOptions::AddJVMArguments(
const string &host_javabase, vector<string> *result,
const vector<string> &user_options, string *error) const {
- // TODO(bazel-team): see what tuning options make sense in the
- // open-source world.
+ // Configure logging
+ const string propFile = output_base + "/javalog.properties";
+ if (!WriteFile(
+ "handlers=java.util.logging.FileHandler\n"
+ ".level=INFO\n"
+ "java.util.logging.FileHandler.level=INFO\n"
+ "java.util.logging.FileHandler.pattern="
+ + output_base + "/java.log\n"
+ "java.util.logging.FileHandler.limit=50000\n"
+ "java.util.logging.FileHandler.count=1\n"
+ "java.util.logging.FileHandler.formatter="
+ "java.util.logging.SimpleFormatter\n",
+ propFile)) {
+ perror(("Couldn't write logging file " + propFile).c_str());
+ } else {
+ result->push_back("-Djava.util.logging.config.file=" + propFile);
+ }
return blaze_exit_code::SUCCESS;
}