Troubleshooting Experience Server – Logging

During development we sometime face issues where system/application does not work in expected way. And then we need some help from the system to troubleshoot the issue. Hallmark of a good system/framework is how it helps a developer to nail down an issue quickly. To facilitate that Experience Server provides various options which help in troubleshooting a problem quickly. In a series of post I would try to provide some details around these options.

This post would provide details around Logging. Experience Server emits quite a bit of log in various folder.

  • CRX Repository Logs – crx-quickstart/logs/crx/error.log
  • Sling Logs – crx-quickstart/logs/error.log and crx-quickstart/launchpad/logs/error.log
  • Request logs – crx-quickstart/logs/request.log and crx-quickstart/logs/access.log

There are many other log files which are created. Refer to Finding the Logs section of getting started guide for more details.

CRX Repository Logs

The logs from the repository are stored in crx-quickstart/logs/crx/error.log. It can be configured by modifying the crx-quickstart/server/runtime/0/_crx/WEB-INF/log4j.xml. For any changes made in this file to be picked up you would need to restart the server.

Through this log4j.xml you can enable logs for Jackrabbit i.e. org.apache.jackrabbit category. Refer to Log4j XML Format Guide for details around various configuration options available

Sling Logs

Sling logs captures the logs from various OSGi bundles. Most of the time you would be looking in Sling logs for logs from your custom components, third party bundles etc. These logs are stored in crx-quickstart/logs/error.log. You can change the location and log level (defaults to Information) by going to http://localhost:4502/system/console/configMgr/org.apache.sling.commons.log.LogManager.

Apache Sling Logging Configuration

Through LogManager you can configure global settings. However turning the global log level to debug would emit quite a bit of logs. To enable logging for specific categories you would need to add Logger configuration. For this go to http://localhost:4502/system/console/configMgr/org.apache.sling.commons.log.LogManager.factory.config. It would show a dialog like. Instead you would need to go to http://localhost:4502/system/console/configMgr. There look for Configuration with name Apache Sling Logging Logger Configuration which has a plus sign in the end. Click on the plus sign and it would open up a dialog as shown below

Apache Sling Logging Logger Configuration Now lets say you want to debug the authentication logic. The authentication logic is implemented in the org.apache.sling.auth.core bundle. So

  1. Add ‘org.apache.sling.auth.core’ in the Logger field and click the plus (highlighted) button.
  2. Add more categories as required and save.
  3. Set the ‘log Level’ to Debug
  4. Save

From now on the debug level authentication logs would be stored in the crx-quickstart/launchpad/logs/error.log. Note the error.log file is in crx-quickstart/launchpad/logs folder instead of crx-quickstart/logs folder. To edit the configuration later go to http://localhost:4502/system/console/configMgr and look for ‘Apache Sling Logging Logger Configuration’

Apache Sling Logging Logger Configuration To edit click on the pencil button. This would bring up the earlier dialog where you can tweak the settings again. To add new configuration click on the ‘Plus’ (highlighted) button

Request Logs

Sling provides extensive support to log various information at the before and after processing client requests. The log format specification follows the definition of the format argument for the LogFormat and CustomLog directives of Apache httpd. These logs are stored in crx-quickstart/logs/request.log. A new logger can be added by accessing http://localhost:4502/system/console/configMgr/org.apache.sling.engine.impl.log.RequestLoggerService. Refer to Sling Request Logging for more details about various options

Apache Sling Customizable Request Data Logger

For example with the default logging format for request is %{end}t [%R] <- %s %{Content-Type}o %Dms the output appears as below

28/Jul/2011:21:01:57 +0530 [2] <- 200 text/html 3313ms
28/Jul/2011:21:01:57 +0530 [3] -> GET /libs/cq/core/content/login/login.css HTTP/1.1
28/Jul/2011:21:01:57 +0530 [3] <- 200 text/css 16ms
28/Jul/2011:21:01:57 +0530 [4] -> GET /libs/cq/core/content/login/favicon.ico HTTP/1.1
28/Jul/2011:21:01:57 +0530 [5] -> GET /libs/cq/core/content/login/login.js HTTP/1.1
28/Jul/2011:21:01:57 +0530 [5] <- 200 application/x-javascript 0ms

This log is useful in cases where we want to check for specific headers in request when request is forwarded from dispatcher.

Resources

Update

14-Oct-2011 – Thanks to @justinedelson for highlighting an issue in the steps required to enable logging for specific categories. The required steps are now updated
VN:F [1.9.22_1171]
Was this helpful? Please rate the content.
Rating: 0.0/10 (0 votes cast)
This entry was posted in ADEP, Experience Services and tagged , . Bookmark the permalink.

Comments are closed.