Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Where to find local AEM logs inside a Docker Container ?

abhifoyou
Level 2
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
Theo_Pendle
Correct answer by
Community Advisor
Community Advisor

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
Theo_Pendle
Correct answer by
Community Advisor
Community Advisor

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

abhifoyou
Level 2
Level 2
Thank you so much theop76211228 for your reply. This pointers would definitely help.
BrianKasingli
Community Advisor
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.

abhifoyou
Level 2
Level 2
Thank you so much for your reply. I will try this commands.
abhifoyou
Level 2
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.
BrianKasingli
Community Advisor
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"
Theo_Pendle
Community Advisor
Community Advisor
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
abhifoyou
Level 2
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.