AEM in 40 Days
CalendarPhase 6 · Deploy, Operate, Secure

Day 38 of 40

Debugging

Logs, remote debugging, OSGi consoles and the Repository Browser

~50 min read6 videos7 source pages

By the end of today you should be able to

  1. Read AEM logs and know which log answers which question
  2. Attach a remote debugger to a local AEM instance
  3. Use the OSGi consoles to diagnose bundles, components and Sling Models
  4. Use the Cloud Service Developer Console and Repository Browser

The logs

Locally these live in crx-quickstart/logs; on Cloud Service you download them from Cloud Manager or tail them with the AIO CLI.

  • error.log — application logging and stack traces. Your first stop, almost always.
  • request.log — one line in and one out per request, with duration and status. The place to find slow requests.
  • access.log — HTTP access in a standard format.
  • stdout.log / stderr.log — startup output, including problems too early for the normal logging framework.

On Cloud Service, Dispatcher and CDN logs are separate downloads. When a request behaves oddly you often need the CDN log (did it hit the cache?) and the AEM log (what did AEM do?) side by side.

# Tail Cloud Service logs from the command line
aio aem:rde:logs                     # for an RDE
# or download per-environment log files from Cloud Manager

Custom log files

Rather than drowning your project's logging in error.log, configure a Sling Logging Logger writing your package to its own file at DEBUG, while the root logger stays at INFO. It is an OSGi factory configuration, so it ships in ui.config and can be run-mode scoped — DEBUG on dev, WARN on production.

Remote debugging

Start the local instance with the JVM debug agent:

java -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005 \
     -jar aem-author-p4502.jar

Then create a Remote JVM Debug configuration in your IDE pointing at localhost:5005, attach, and set breakpoints in your Sling Models and services as you would in any Java application.

Debug locally, not in the cloud

Remote debugging attaches to a local instance. Cloud Service does not expose a debug port — which is exactly why being able to reproduce a problem on your local SDK is such a valuable skill. An RDE narrows the gap by letting you deploy to real cloud infrastructure in seconds.

The OSGi consoles

Four pages cover most diagnosis:

  • /system/console/bundles — is my bundle Active? If not, which import is unsatisfied?
  • /system/console/components — is my component satisfied? If not, which reference failed to bind?
  • /system/console/slingmodels — is my model registered, and for which resource types and adaptables?
  • /system/console/configMgr — what configuration actually applied?

Two more worth knowing:

  • /system/console/status-slingresourceresolver — shows resource resolver mappings, invaluable when a URL resolves somewhere unexpected.
  • /system/console/jmx — JMX beans, including repository statistics and session counts. Rising session counts point at unclosed resolvers.

Cloud Service tooling

Production does not expose the Felix console. Instead:

  • Developer Console — reachable per environment from Cloud Manager. Provides bundle and component status, Sling Model registrations, resource resolution testing, and — genuinely useful — query performance analysis that flags traversals.
  • Repository Browser — a read-only view of the repository on a Cloud Service environment. This is your replacement for CRXDE Lite in the cloud: you can confirm whether content and structure are actually as you expect, without any ability to modify them.
  • Build and deployment logs in Cloud Manager, for failures that never reach a running instance.

A workable order of attack

  1. Is the code deployed and running? Bundle Active, component satisfied.
  2. Is the content what you think it is? Repository Browser or CRXDE.
  3. Is the configuration what you think it is? configMgr — check the run mode.
  4. What does the log say? error.log around the timestamp.
  5. Is a cache involved? Response headers, then the Dispatcher docroot.
  6. Only then reach for a debugger.
Today's takeaway

Four consoles answer most questions. Log your own package to its own file. Remote debugging is a local activity; in the cloud you have the Developer Console, Repository Browser and logs.

Watch

Adobe's own videos for this topic. They load only when you press play.

Debugging AEM as a Cloud Service SDK’s local quickstart using logs
Remote debugging the AEM as a Cloud Service SDK’s local quickstart
Debugging AEM as a Cloud Service SDK’s local quickstart using the Bundles web console
Debugging AEM as a Cloud Service SDK’s local quickstart using the Components web console
Debugging AEM as a Cloud Service SDK’s local quickstart using the Sling Models web console
Debugging AEM as a Cloud Service with Repository Browser

Read on Experience League

The primary sources these notes are drawn from.

Your notes

Saved automatically to this browser.

Check yourself

10 questions on today's material. 80% to pass.

Take the quiz