SbloodyS commented on code in PR #18098:
URL:
https://github.com/apache/dolphinscheduler/pull/18098#discussion_r3071168451
##########
dolphinscheduler-master/src/main/resources/logback-spring.xml:
##########
@@ -51,6 +53,25 @@
</appender>
</sift>
</appender>
+ <appender name="TASKOUTPUTLOGFILE"
class="ch.qos.logback.classic.sift.SiftingAppender">
Review Comment:
We should add an automatic cleaning policy like other logs.
##########
dolphinscheduler-task-plugin/dolphinscheduler-task-http/src/main/java/org/apache/dolphinscheduler/plugin/task/http/HttpTask.java:
##########
@@ -125,10 +131,33 @@ private void validateResponse(String body, int
statusCode) {
}
// default success log
- log.info("http request success, url: {}, statusCode: {}, body: {}",
httpParameters.getUrl(), statusCode, body);
+ logHttpResponse("http request success, url: {}, statusCode: {}, body:
{}", statusCode, null, body);
exitStatusCode = TaskConstants.EXIT_CODE_SUCCESS;
}
+ private void logHttpResponse(String message, int statusCode, String
checkCondition, String body) {
+ if (StringUtils.isBlank(taskExecutionContext.getTaskOutputLogPath())) {
+ if (checkCondition == null) {
+ log.info(message, httpParameters.getUrl(), statusCode, body);
+ } else {
+ log.error(message, httpParameters.getUrl(), statusCode,
checkCondition, body);
+ }
+ return;
+ }
+
LogUtils.setTaskInstanceLogFullPathMDC(taskExecutionContext.getLogPath());
+ try (
+ LogUtils.MDCAutoClosableContext ignored =
+
LogUtils.withTaskOutputLogPathMDC(taskExecutionContext.getTaskOutputLogPath()))
{
+ if (checkCondition == null) {
+ TASK_OUTPUT_LOGGER.info(message, httpParameters.getUrl(),
statusCode, body);
+ } else {
+ TASK_OUTPUT_LOGGER.info(message, httpParameters.getUrl(),
statusCode, checkCondition, body);
+ }
+ } finally {
+ LogUtils.removeTaskInstanceLogFullPathMDC();
+ }
+ }
Review Comment:
Logic like this should not be customized by users, but should be handled at
spi level.
--
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]