Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.
SOLVED

Where to find local AEM logs inside a Docker Container ?

Avatar

Level 2

hi Team,

 

As my organization uses a docker container to run local AEM instance, I am NOT able to find log files or even crx/quickstart folder to play with.

I understand this question is more specific to AEM with docker, but has anyone in this forum happen to find the AEM log files for the local instance ? Otherwise, how we can debug our code while AEM running inside docker ?

 

I have been asked to use the below command to tail the logs, but I want to know the actual location of the AEM logs folder. 

 

docker exec -it aem tail --lines 0 -f ./crx-quickstart/logs/error.log

 

Thanks !

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi, 

Of course this will completely depend on how the Docker image is set up.. but here are some pointers:

  1. Check the docker-compose.yaml or docker command which launched the container to see if a drive was mounted in a specific way or if a volume is used to store the logs.
  2. Even if you can't find the log files there are a couple of ways to see the logs:
    1. You can check the contents of all log files by navigating to /system/console/slinglog in your browser. You can even download a zip containing all the logs.
    2. If you want to see the logs in real-time, head over to CRX DE and open the Console tab (where the node properties are) un-check the Disable console button and you will get a tail of the error.log:
      Selection_096.png
  3. You run a remote debug listener on AEM using your favorite IDE (I use IntelliJ). To do so, just make sure that your AEM instance is running a debug port (30303 for example) and that the port is exposed by the container.

PS: I see you are looking for ./crx-quickstart inside the container, but a typical place to find AEM and the crx-quickstart folder is at /opt/aem/[author|publisher]/crx-quickstart
 

View solution in original post

9 Replies

Avatar

Correct answer by
Level 10

Hi, 

Of course this will completely depend on how the Docker image is set up.. but here are some pointers:

  1. Check the docker-compose.yaml or docker command which launched the container to see if a drive was mounted in a specific way or if a volume is used to store the logs.
  2. Even if you can't find the log files there are a couple of ways to see the logs:
    1. You can check the contents of all log files by navigating to /system/console/slinglog in your browser. You can even download a zip containing all the logs.
    2. If you want to see the logs in real-time, head over to CRX DE and open the Console tab (where the node properties are) un-check the Disable console button and you will get a tail of the error.log:
      Selection_096.png
  3. You run a remote debug listener on AEM using your favorite IDE (I use IntelliJ). To do so, just make sure that your AEM instance is running a debug port (30303 for example) and that the port is exposed by the container.

PS: I see you are looking for ./crx-quickstart inside the container, but a typical place to find AEM and the crx-quickstart folder is at /opt/aem/[author|publisher]/crx-quickstart
 

Avatar

Level 2
Thank you so much theop76211228 for your reply. This pointers would definitely help.

Avatar

Community Advisor

Hi, I've been working on local AEM projects with Docker for some time. Here's how you can achieve tailing logs for your running local docker AEM instance. 

Assuming that your system supports UNIX commands, and your local docker instances are running, here goes:

  1. docker ps - this will list all running instances along with the container ID; copy the container ID.
  2. docker exec -it <containerID> bash - this will execute an interactive bash shell on the container.
  3. tail -f .../crx-quickstart/logs/error.log - tail -f command will wait for new strings in the file and show these strings dynamically. 

Docker documentation can be found here: https://docs.docker.com/engine/reference/commandline/exec/

I hope this helps.

Avatar

Level 2
Thank you so much for your reply. I will try this commands.

Avatar

Level 2
The commands are working fine Thanks. Additionally, Do you know how to open a debug port in AEM inside a docker ?? Or how do i know if my local AEM instance inside docker is running a debugger port.

Avatar

Community Advisor

Your DockerFile should include some environment variables:

environment:
CQ_JVM_OPTS: "-server -Xmx1024m -Xdebug -agentlib:jdwp=transport=dt_socket,address=7000,server=y,suspend=n -XX:MaxPermSize=256M -Djava.awt.headless=true -Djava.io.tmpdir=/tmp -Dorg.apache.sling.commons.log.level=ERROR -Dorg.apache.sling.commons.log.file="
CQ_RUNMODE: "publish,nosamplecontent"
CQ_PORT: "4503"

Avatar

Level 10
Following what Brian said about starting AEM with -Xdebug, you will also need to expose the debug port on the docker container (otherwise you won't be able to access it from outside). Docker docs on exposing ports here: https://docs.docker.com/engine/reference/commandline/run/#publish-or-expose-port--p---expose

Avatar

Level 2
Thanks theop76211228 and Briankasingli . The debug port and CQ_JVM_OPTS are already configured in docker-compose.yml file. I did not have to expose it explicitly. Looks like it is already exposed.