As a newbie to Docker: I am using a Docker host to run around 11 containers, and one of the containers is running java application, in which I used log4j logging to log. How can I access only the logs while running the Docker compose. I have tried to capture the logs to a log4j.log file, but this only creates after the termination of the java application.
Asked
Active
Viewed 8,112 times
4
-
It may more useful to setup a network logging. You send the logs outside the container (say to a central location) and analyse it. See http://stackoverflow.com/questions/11759196/log4j-how-to-use-socketappender – Jayan Apr 24 '15 at 07:13
1 Answers
3
Assuming that you have configured log4j to log into std out and you are running application by using commnad: java -jar ...
you should be able to check logs using:
$ docker-compose logs name_of_container

Alejandro Galera
- 3,445
- 3
- 24
- 42

wsl
- 8,875
- 1
- 20
- 24
-
It works!, thanks for the tip, One small issue is that, with one server I have used supervisor to spawn two processes, one for execution of java with ant script and other for starting tomcat7. In this case am not able to see the logs. – Balu Apr 26 '15 at 14:37
-
Generally it is not a good idea to have supervisor or run more than one application inside single container. It can cause you a problem for example if one of the applications will stop working. – wsl Apr 27 '15 at 07:06
-