Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker- How to use syslog to record logs on host machine?

I wish to keeps the logs of my container to a file in my host machine for every container. I read about doing the same via logging driver.

Since my host machine runs ubuntu 14.04, which has rsyslog running by default, I thought to use syslog.

What I did was used following command to run the container:

docker run -it --log-driver=syslog --log-opt syslog-address=udp://localhost:514 prashant23/ubuntu-java:sample-jdbc-project bash

and I went inside the container without any error. That's all? How do I know that where I can see logs on my host machine? Did I do everything right? I have no idea about syslog. Do I need to configure syslog on my container too? Is there any better approach to achieving the same.

I am not sure what should I use as syslog-address. From where I can get the value of this parameter? I somewhere read default is udp://localhost:514

like image 480
Prashant Prabhakar Singh Avatar asked May 10 '17 10:05

Prashant Prabhakar Singh


Video Answer


1 Answers

Using syslog driver, your Docker container will write log data to /var/log/syslog file. You should find your container logs in that file.

syslog-address is only needed if you use an external syslog server, which doesn't seem to be your case.

Using default driver json-file, Docker will create a log file in this path.

/var/lib/docker/containers/[container-id]/[container-id]-json.log

like image 198
kstromeiraos Avatar answered Oct 04 '22 00:10

kstromeiraos