我有一个Spring Cloud Task接收器应用程序,它将触发Spring Cloud Task。
@SpringBootApplication
@EnableBinding(Sink.class)
@RestController
@EnableScheduling
@EnableTaskLauncher
@Slf4j
public class FileTaskLauncherApp {
@Autowired
private Sink sink;
@Value("${spring.task.artifactory.url}")
private String uri;
@Value("${spring.task.name:file_task_launcher}")
private String taskName;
@GetMapping("/triggerTask")
public String publishTask(){
log.info("Publishing task with task launcher request...");
Map<String, String> prop = new HashMap<>();
prop.put("server.port", "0");
Map<String,String> deployProp=new HashMap<>();
deployProp.put("deployer.*.local.inheritLogging","true");
TaskLaunchRequest request = new TaskLaunchRequest(
uri, null,
prop,
deploymentProp, taskName);
GenericMessage<TaskLaunchRequest> message = new
GenericMessage<TaskLaunchRequest>(
request);
this.sink.input().send(message);
return "SUCCESS";
}
}
但是Spring云任务接收器将调用Spring Cloud Task,并且每个任务都是一个短暂的微服务,具有自己的功能。我想将应用程序日志从Spring云任务重定向到任务接收器应用程序。
这是我的application.properties:
server.port=8084
spring.cloud.stream.kafka.binder.brokers= localhost:2181
spring.cloud.stream.bindings.input.destination=fileTask
spring.task.artifactory.url=maven://com.tgt.fulfillment:file-generation-task:1.0.1-SNAPSHOT
spring.task.name=file_task_launcher
deployer.*.local.inheritLogging=true
这是我的日志,来自任务接收器应用程序
12:40:39.057 [http-nio-8084-exec-1] INFO o.s.c.task.launcher.TaskLauncherSink - Launching Task for the following uri maven://com.test:file-generation-task:1.0.1-SNAPSHOT
12:40:39.140 [http-nio-8084-exec-1] INFO o.s.c.d.spi.local.LocalTaskLauncher - Command to be executed: /Library/Java/JavaVirtualMachines/jdk1.8.0_171.jdk/Contents/Home/jre/bin/java -jar /Users/z003c1v/.m2/repository/com/test/file-generation-task/1.0.1-SNAPSHOT/file-generation-task-1.0.1-SNAPSHOT.jar
12:40:39.153 [http-nio-8084-exec-1] INFO o.s.c.d.spi.local.LocalTaskLauncher - launching task file_task_launcher-2c630ad9-acbb-43e0-8140-3ce49506f8e2
Logs will be in /var/folders/y5/hr2vrk411wdg_3xl3_10r295rp30bg/T/file_task_launcher7177051446839079310/1539587439103/file_task_launcher-2c630ad9-acbb-43e0-8140-3ce49506f8e2
根据下面的春季文档,通过在部署属性中启用deployer。*。local.inheritLogging = true,应将应用程序日志重定向到服务器日志,但这不会发生。
参考:http://docs.spring.io/spring-cloud-dataflow/docs/1.4.0.RELEASE/reference/htmlsingle/#_logging
有人可以帮助我尽快解决这个问题。
答案 0 :(得分:0)
您可以共享由任务启动器sink
组成的流定义吗?
inheritLogging
属性是本地部署者属性,因此,当您在应用级别的属性中deploying
流非时应指定该属性上面提到过。
类似的东西:
stream deploy --name mystream --properties“ deployer。*。local.inheritLogging = true”