Assuming that you have multiple containers and you want to aggregate the logs into a single file, you need to use some log aggregator like fluentd. fluentd is supported as logging driver for docker containers.
So in docker-compose, you need to define the logging driver
service1:
image: webapp:0.0.1
logging:
driver: "fluentd"
options:
tag: service1
service2:
image: myapp:0.0.1
logging:
driver: "fluentd"
options:
tag: service2
The second step would be update the fluentd conf to cater the logs for both service 1 and service 2
<match service1>
@type copy
<store>
@type file
path /fluentd/log/service/service.*.log
time_slice_format %Y%m%d
time_slice_wait 10m
time_format %Y%m%dT%H%M%S%z
</store>
</match>
<match service2>
@type copy
<store>
@type file
path /fluentd/log/service/service.*.log
time_slice_format %Y%m%d
time_slice_wait 10m
time_format %Y%m%dT%H%M%S%
</store>
</match>
In this config, we are asking logs to be written to a single file to this path
/fluentd/log/service/service.*.log
and the third step would be to run the customized fluentd which will start writing the logs to file.
Here is the link for step by step instructions
Bit Long, but correct way since you get more control over log files path etc and it works well in Docker Swarm too .