Skip to content

Commit

Permalink
[Java] make java worker log file prefix (default to java-worker) conf…
Browse files Browse the repository at this point in the history
…igurable (#33797)

For java worker, it's log file always being prefixed with "java-worker". And in python log_monitor.py, it hardcodes "java-worker*.log" to be polled for new log msg periodically. Some configs, like log_to_driver and RAY_BACKEND_LOG_LEVEL, don't prevent the log monitor from polling and publishing logs to gcs. To save some CPU cycle and network bandwidth, especially if there is large amount of logs produced from JVM, we can have an option. like a JVM system property, to set log file prefix for java worker instead of hard coded to "java-worker".
  • Loading branch information
jiafuzha authored Apr 10, 2023
1 parent bd525f3 commit 10861d9
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,12 @@ public static synchronized void setupLogging(RayConfig rayConfig) {
RootLoggerComponentBuilder rootLoggerBuilder = globalConfigBuilder.newAsyncRootLogger(level);
rootLoggerBuilder.addAttribute("RingBufferSize", "1048576");
final String javaWorkerLogName = "JavaWorkerLogToRollingFile";
String logFileName = "java-worker-" + jobIdHex + "-" + SystemUtil.pid();
String logFileName =
rayConfig.getInternalConfig().getString("ray.logging.file-prefix")
+ "-"
+ jobIdHex
+ "-"
+ SystemUtil.pid();
setupLogger(
globalConfigBuilder,
rayConfig.logDir,
Expand Down
4 changes: 4 additions & 0 deletions java/runtime/src/main/resources/ray.default.conf
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ ray {
max-file-size: 500MB
// Maximum number of backup files to keep around.
max-backup-files: 10
// log file name prefix of default logger
// change it to something else other than "java-worker" if you dont want
// ray log monitor to poll and publish log to gcs from the log file
file-prefix: java-worker

// Configuration for the customized loggers.
// For example, if you want to customize the file name and the log pattern for a logger
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,14 @@ public void testCreateRayConfig() {
Assert.assertEquals(
Collections.singletonList("path/to/ray/job/resource/path"), rayConfig.codeSearchPath);
}

@Test
public void testGetLogFilePrefix() {
String key = "ray.logging.file-prefix";
RayConfig rayConfig = RayConfig.create();
Assert.assertEquals("java-worker", rayConfig.getInternalConfig().getString(key));
System.setProperty(key, "raydp-java-worker");
rayConfig = RayConfig.create();
Assert.assertEquals("raydp-java-worker", rayConfig.getInternalConfig().getString(key));
}
}

0 comments on commit 10861d9

Please sign in to comment.