0

I am having a Spring cloud Task sink application, that will trigger the 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";
       }
    }

But Spring cloud task sink will be calling Spring Cloud Task and each task is a short lived micro service having its own functionality. I wanted to redirect application logs from Spring cloud task into Task sink application.

This is my 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

This is my logs coming from task sink application

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

As per the below spring documentation by enabling deployer.*.local.inheritLogging=true in deployment properties, application logs should be redirected to server logs, but this is not happening.

Reference: http://docs.spring.io/spring-cloud-dataflow/docs/1.4.0.RELEASE/reference/htmlsingle/#_logging

Could somebody please help me in resolving this issue at the earliest.

Ravikiran
  • 45
  • 1
  • 7

1 Answers1

0

Can you share your stream definition that consists of the task launcher sink?

The inheritLogging property is a local deployer property and hence it should be specified when deploying the stream not at the app level property you mentioned above.

Something like:

stream deploy --name mystream --properties "deployer.*.local.inheritLogging=true”

Ilayaperumal Gopinathan
  • 4,099
  • 1
  • 13
  • 12
  • Thank you for the inputs. I am not defining any Task Sink explicity, i am making use of org.springframework.cloud.stream.messaging.Sink which will trigger the task. I am setting the deployer.*.local.inheritLogging property as a deployment property before calling the task. – Ravikiran Oct 22 '18 at 10:50
  • I understand that you are using Sink app to trigger the task. But, this deployer property `"deployer.*.local.inheritLogging=true”` should be specified when you deploy the stream not via the application.properties. – Ilayaperumal Gopinathan Oct 22 '18 at 11:05
  • @IlayaperumalGopinathan I am looking to aggregate all the logs in one place. I have scdf and compsed task runner where in It is having 7 short lived tasks executing. I want to aggregate all the 7 tasks log along with composed task runner log. Please advise – upadhyayRakes May 16 '20 at 03:52