rickchengx commented on code in PR #13654:
URL:
https://github.com/apache/dolphinscheduler/pull/13654#discussion_r1121638781
##########
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:
Hi, @ruanwenjun thanks a lot for your comment. I've changed to `rolling
view`.
Specifically, I moved some logging related reading functions to a public
class `common/LogUtils`, so that both`LoggerServiceImpl` and
`LoggerRequestProcessor` can use.
--
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]