ruanwenjun commented on code in PR #13654:
URL: 
https://github.com/apache/dolphinscheduler/pull/13654#discussion_r1121633891


##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/LoggerServiceImpl.java:
##########
@@ -202,19 +207,33 @@ private String queryLog(TaskInstance taskInstance, int 
skipLineNum, int limit) {
         log.info("Query task instance log, taskInstanceId:{}, 
taskInstanceName:{}, host:{}, logPath:{}, port:{}",
                 taskInstance.getId(), taskInstance.getName(), host.getIp(), 
taskInstance.getLogPath(), host.getPort());
 
-        StringBuilder log = new StringBuilder();
+        StringBuilder sb = new StringBuilder();
         if (skipLineNum == 0) {
             String head = String.format(LOG_HEAD_FORMAT,
                     taskInstance.getLogPath(),
                     host,
                     Constants.SYSTEM_LINE_SEPARATOR);
-            log.append(head);
+            sb.append(head);
         }
 
-        log.append(logClient
-                .rollViewLog(host.getIp(), host.getPort(), 
taskInstance.getLogPath(), skipLineNum, limit));
+        String logContent = logClient
+                .rollViewLog(host.getIp(), host.getPort(), 
taskInstance.getLogPath(), skipLineNum, limit);
 
-        return log.toString();
+        if (StringUtils.isEmpty(logContent) && 
RemoteLogUtils.isRemoteLoggingEnable()) {
+            // get task log from remote target
+            try {
+                RemoteLogUtils.getRemoteLog(taskInstance.getLogPath());
+                File logFile = new File(taskInstance.getLogPath());
+                logContent = FileUtils.readFileToString(logFile, 
Charset.defaultCharset());
+                FileUtils.delete(logFile);
+            } catch (IOException e) {
+                log.error("Error while getting log from remote target", e);
+            }
+        }
+
+        sb.append(logContent);

Review Comment:
   We need to support rolling view, rather than read the whole log file, 
otherwise this might cause OOM.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to