Apr 18, 2013

Extract replication logs to separate files

Posted by Vianney Baron

Replication is a key feature of the AEM solution. As such it should be carefully monitored, and there are a couple of ways to achieve this:

  • JMX: since version 5.5 AEM offers JMX MBeans to monitor a number of aspects on your instance, including the replication Agents, the complete list is available here:¬†http://localhost:4502/system/console/jmx.
  • Logs: replication APIs output a certain volume of logs, that can be used to monitor the various agents in real time.

Now option 2 is probably the simplest to use, but all of these logs are written in the main AEM log file: crx-quickstart/logs/error.log. This means that this file will grow fast on large infrastructures where a lot of replications are performed, and monitoring replication can become quite cumbersome.

To avoid this we can arrange for these logs to be written in different files, by creating a new Logger configuration.

AEM logging is configured using the standard Felix configuration here: http://localhost:4502/system/console/configMgr. Locate the following configuration and click on the plus button:


Then fill in the configuration as follow:


This particular configuration will redirect logs from the Replication Agent called publish1 to a separate: logs/replication-publish1.log. Note that if needed you can list several agents to redirect them all to the same file, simply click on the plus button next to Logger.

However you might find that having one file per Agent can be useful. To achieve this just create a new configuration as indicated above and voilà!

Now to ensure the logs are properly rotated you can create a Writer configuration by clicking the plus button here:


And use the following values:


This way the log file will be rotated each day, and 5 days will be archived. Note that we could also use the file size to rotate the files.