Custom Logging with AEM Logger

Logging is a key element in the development of secure and stable applications. You can use Sling Logging to diagnose major issues in Adobe Experience Manager (AEM), such as slow load times and component errors or page load failures.

AEM allows the configuration for the following through OSGi configurations:

  • Global parameters for the central logging service
  • Request data logging; a particular logging configuration for request information
  • Particular settings for individual services

Global Logging:

The root logger is configured using Apache Sling Logging Configuration. This defines the global AEM logging settings:

  • The central log file location

  • The logging level

  • Version rotation; either time interval or maximum size

  • The number of versions to be maintained

  • The format to use when logging messages

Apache Sling Logging Configuration

By default, logs can be found in the following locations:

  • crx-quickstart/launchpad/logs

  • crx-quickstart/server/logs

  • crx-quickstart/logs

The log levels are as follows:

0Fatal errorThe action is unsuccessful, and the installer cannot carry on.
1ErrorThe action has failed. The installation proceeds, but a part of CRX is not installed correctly and will not work.
2WarningThe action has succeeded but ran into problems. CRX may or may not work correctly.
3InformationThe action has succeeded.

Loggers and Writers for Individual Services:

Apart from the global settings for logging, AEM allows you to configure specific settings for an individual service:

  • The individual log file location
  • The specific logging level
  • The number of versions to be maintained
  • The format to use when logging messages
  • Version rotation; either time interval or maximum size
  • The logger (the OSGi service delivering the log messages)

This enables you to channel log messages into a separate file for a single service.

AEM practices the following to log messages to file:

  • An OSGi service writes a log message.
  • A Logging Logger formats the message according to your specification.
  • A Logging Writer writes these messages to a physical file which is defined.

These elements are linked by the below factors for appropriate elements:

  • Logger (Logging Logger) - Defines the service for generating the messages.
  • Log File (Logging Logger) - Defines the physical file for storing the log messages.
  • Log File (Logging Writer) - Defines the physical file that the log messages will be written to.

Standard Loggers and Writers

A standard AEM installation includes several Loggers and Writers.

If required, these can be customized, although for most installations the standard configuration is suitable.

Custom Loggers and Writers

Custom Logger / Writer pairs can also be defined:

1. Creates new instance of the Factory Configuration Apache Sling Logging Logger Configuration.

  • Specify the Log File.

  • Specify the Logger.

  • Configure the other parameters as required.

Apache Sling Logging Logger Configuration

2. Create new instances of the Factory Configuration Apache Sling Logging Writer Configuration.

  • Specify the Log File – which must match that is specified in the Logger.

  • Configure the other parameters as required.

Apache Sling Logging Writer Configuration

These guidelines should help you better know the logging capabilities of Sling. With Royal Cyber’s AEM expertise you can start logging or expand the scope of any logging you already have. For more information on AEM logger, you can write to us at info@royalcyber.com or visit www.royalcyber.com.

1 Comment

  1. Mr T says:

    I want config file access log. How?

Leave a Reply