Starting AEM in debug mode allows you to debug Java code, inspect logs, and analyze AEM's internal processes. This can be especially useful for troubleshooting issues and examining the behavior of components or services.
Here’s how to start AEM in debug mode :
To run AEM in debug mode via the command line:
Navigate to your AEM installation directory:
aem/author or aem/dispatcher.Edit the start script:
start.bat file.start.sh file.Add Debugging Parameters:
Find the section where the AEM JVM is started, and add the following JVM options for remote debugging:
For Windows (start.bat):
set AEM_JVM_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000
For Linux/macOS (start.sh):
export AEM_JVM_OPTS="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000"
-Xdebug: Enables debugging.-Xrunjdwp:transport=dt_socket: Use the socket transport for remote debugging.server=y: AEM will listen for debugger connections.suspend=n: AEM will not wait for the debugger to attach before starting.address=8000: The debugger port AEM listens on (you can change it if needed).Restart AEM:
Run the script (start.bat or start.sh) to start AEM in debug mode. This will start AEM with remote debugging enabled on port 8000.
Once AEM is running in debug mode, you can attach your IDE debugger to the process:
localhost and Port to 8000 (or the port you used).localhost and Port to 8000.Now, you can set breakpoints in your Java code, step through it, and inspect variables!
Access the AEM Logs:
You can find the logs in the crx-quickstart/logs/ directory. Look for the error.log or aem-error.log for issues related to Java exceptions.
Enable More Verbose Logging:
For additional logging output, you can modify the log configuration file (logback.xml) located in the crx-quickstart directory to increase the verbosity.
start.bat or start.sh to include the Java debug options.localhost:8000 to start debugging.