Redirecting Tomcat logs for Docker - tooltwist/documentation GitHub Wiki
Most Docker containers send their log output to the console, so it can be displayed with the docker logs
commands. Our normal Tomcat setup writes output to either the Tomcat default location ($TOMCAT_HOME/logs/catalina.out
) or to $TOOLTWIST_HOME/logs/toolwist*.log
.
During a tooltwist application startup, we define where to send application logs in $TOOLTWIST/conf/logback.xml
. Edit this file and include or update these sections:
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d %-5p %c{1} - %m%n</pattern>
</encoder>
</appender>
<root level="DEBUG">
<appender-ref ref="STDOUT"/>
</root>
This will cause the output to be sent to tomcat's standard output, which by default normally goes to $CATALINA_HOME/logs/catalina.out
.
The next step is to send the contents of catalina.out to the output of the Docker container. To do this, our base Docker images (tooltwist/docker-base-tooltwist
and tooltwist/docker-base-designer
) run tail -f catalina.out
once Tomcat has been started, during the server startup.
[Most ToolTwist images are created from these base images]