Hi @smrithigo,
Yes, this is definitely possible in AEM 6.5. Since AEM uses Logback internally, you can easily output logs in JSON format by adding a JSON encoder and defining a custom appender.
Here’s the simplest way to achieve it:
1. Add the dependency
Include the Logstash Logback Encoder in your project’s pom.xml:
<dependency>
<groupId>net.logstash.logback</groupId>
<artifactId>logstash-logback-encoder</artifactId>
<version>7.3</version>
</dependency>
- Create a JSON log appender
In /crx-quickstart/conf/logback.xml, add:
<appender name="JSON" class="ch.qos.logback.core.FileAppender">
<file>${crx.home}/logs/aem-json.log</file>
<encoder class="net.logstash.logback.encoder.LogstashEncoder" />
</appender>
<logger name="com.mycompany" level="INFO" additivity="false">
<appender-ref ref="JSON" />
</logger>
- Deploy & restart AEM
Logs for your package will now be written in JSON format under /crx-quickstart/logs/aem-json.log.
- Connect with Elastic Agent
Point your Elastic Agent/Fleet configuration to read this file as JSON. The structured output will map cleanly to ECS fields and can be correlated with Elastic APM.
This is the most lightweight and clean approach — no core AEM changes, only one encoder dependency and one config file update.
Hope this helps.
Regards,
Manvi Sharma