0
votes

I have a custom docker image with a Spring Boot App that I've deployed to Azure Container Registry and now it is running as an App Service. This container is running Tomcat 8.5 and so I have catalina.out logs and my own custom webapp.log file that are being created in /usr/local/tomcat/logs directory. Running outside of Azure in a docker container I can access and view logs.

However, deployed in the App Service I am unable to retrieve the actual log files, and the only place I can see logs is in the Log Stream. I am using log4j2 and have a the proper config file. enter image description here

Is there a way to access Tomcat catalina and webapp logs? Is it possible to direct the webapp.log to /home/LogFiles/ for a custom container?

I have tried using the following log4j2.xml

<?xml version="1.0" encoding="UTF-8"?>
<Configuration>
<Properties>
    <Property name="filename">webapp.log</Property>
    <Property name="path">$HOME\LogFiles</Property>
</Properties>
<Appenders>
    <Console name="STDOUT" target="SYSTEM_OUT">
        <PatternLayout pattern="[%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %c{1} - %msg%n"/>
    </Console>
    <File name="LOGFILE" fileName="${path}\${filename}">
        <PatternLayout pattern="[%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %c{1} - %msg%n"/>
    </File>
</Appenders>
<Loggers>
    <Logger name="appLogger" level="debug">
        <AppenderRef ref="LOGFILE" level="debug"/>
    </Logger>
    <Root level="info">
        <AppenderRef ref="STDOUT"/>
    </Root>
</Loggers>
</Configuration>
2

2 Answers

0
votes

You log4j2.xml configurations looks good. Is it possible for you to share your container image for me to try out ?

0
votes

To retrieve the log files, I use Kudu to SSH into the home dir of the tomcat app. Once connected, copy the log files of /usr/local/tomcat/logs/ to a directory that is accessible via ftp, where you can download them with Filezilla. Step 1 - COPY : /home/#> cp /usr/local/tomcat/logs/*.log ./LogFiles/ Step 2 - use Filezilla to ftp to the app's /LogFiles folder, where you should see the copied logs. Select all, right click, Download.

I've no idea how you'd send the tomcat log files directly to the LOGFILES folder. I think the Azure app service host for the tomcat web site is a dockerized container app, while the App Service /LOGFILES/ location is storage outside of that.