capture stdout from one container to another

Say I have a docker-compose.yml file like so:

version: '2'
services:
  foo:
    image: foo:4.1.1
    container_name: foo
    command: echo 'this is foo'
  bar:
    image: bar:3.2.0
    container_name: bar
    command: echo 'this is bar'
  baz:
    image: baz:3.2.0
    container_name: baz
    command: cat

is there some configuration I can use so that bar captures the stdout/stderr from foo? Basically I want to setup my containers so that one container can capture the stdio from other containers?

Something like:

foo | baz
bar | baz

so that baz is capturing the stdout. Is this possible using docker-compose? The goal is to configure the process/container which can process the logging from the apps.

Source: StackOverflow