Configure logback.xml file AEM 6.5 | Community
Skip to main content
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

2 replies

HrishikeshKagne
Community Advisor
Community Advisor
May 4, 2024

Hi @cakayastha ,

To configure Logback in Adobe Experience Manager (AEM) 6.5, you need to place the logback.xml file in the appropriate location within your AEM project. Here's how you can do it:

  1. Create logback.xml: First, create your logback.xml file with your custom configuration. This file typically defines the loggers, appenders, and other configurations for Logback. You can refer to the Logback documentation (https://logback.qos.ch/) for details on configuring Logback.

  2. Determine Location: Decide where you want to place your logback.xml file within your AEM project. You have a few options:

    • CRX Repository: You can place the logback.xml file directly in the CRX repository. For example, you might place it under /apps/<your-app>/src/main/content/META-INF/vault/filter.xml if you're using a Maven project structure.

    • Bundle Configuration: You can also include the logback.xml file within your OSGi bundle. In this case, you would typically place it under src/main/resources in your Maven project structure.

  3. Package the Configuration: If you're placing the logback.xml file in the CRX repository, make sure it gets included in your AEM package. Update your Maven POM file or your package definition to ensure that the logback.xml file is included in your package.

  4. Deploy the Package: Deploy the AEM package containing the logback.xml file to your AEM instance. This will ensure that the Logback configuration is applied to your AEM instance.

  5. Restart AEM: After deploying the package, restart your AEM instance to apply the new Logback configuration.

  6. Verify: Once the AEM instance has restarted, verify that your custom Logback configuration is applied. You can check the logs to see if your custom appenders and loggers are working as expected.

By following these steps, you should be able to configure Logback in AEM 6.5 and customize your log files such as access.log and request.log according to your requirements.

Hrishikesh Kagane
Level 2
May 8, 2024

@hrishikeshkagne 

Thanks for your reply. As you suggested  both crx repo path and bundle configuration tried below but did not see logback getting in effect, please guide if  any miss at my end

logback.xml fie :

<configuration>
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>/logs/SampleProject.log</file>
<append>true</append>
<immediateFlush>true</immediateFlush>
<encoder>
<pattern>%d %-5level %X{X-test-ID:-NA} [%thread] %logger{30} %marker- %msg %n</pattern>
</encoder>
</appender>
<logger name="com.test" level="INFO"/>
<root level="TRACE">
<appender-ref ref="FILE" />
</root>
</configuration>

 

 

----->  Added above logback.xml file to path :  ui.app -> src -> main -> content -> jcr_root -> test -> config -> logback.xml file 

 

------> ui.app -> src -> main -> content -> META-INF -> vault -> filter.xml file 

added include :

<include pattern="/apps/test/config(/.*)?"></include>

 

-------> Added configuration file path : 

config -> org.apache.sling.commons.log.LogManger.xml 

org.apache.sling.commons.log.configurationFile="/apps/test/config/logback.xml"

 

 

HrishikeshKagne
Community Advisor
Community Advisor
May 8, 2024

Hi @cakayastha ,

It seems like you've configured Logback properly, but there might be a few things to check to ensure it's working as expected:

  1. Check Log File Location: Ensure that the directory /logs exists in your application's environment and that the application has write permissions to it. Otherwise, Logback might fail silently.

  2. Bundle Configuration: Verify that your bundle configuration is correct. The LogManager configuration in org.apache.sling.commons.log.LogManager.xml should point to the correct path of your logback.xml file. Make sure there are no typos or incorrect paths.

  3. Bundle Activation: Confirm that your bundle is getting activated correctly. Check the logs or console to ensure that there are no errors during the activation of your OSGi bundle.

  4. Logger Configuration: Ensure that the logger configuration in logback.xml is correctly targeting the package or class you want to log. In your case, com.test is set to INFO level, so it should log messages of INFO level or higher.

  5. Override Logging Levels: Verify that there are no other configurations overriding your Logback settings. Sometimes, logging configurations can be overridden by other bundles or configurations.

  6. Restart the Application: After making changes, it's often necessary to restart your application to apply the new logging configurations.

If you've checked all of these and are still not seeing Logback in effect, consider looking at the logs for any error messages related to Logback initialization or configuration. Sometimes Logback itself might log error messages that can help diagnose the issue.

Hrishikesh Kagane
kautuk_sahni
Community Manager
Community Manager
May 16, 2024

@cakayastha Did you find the suggestions helpful? Please let us know if more information is required. Otherwise, please mark the answer as correct for posterity. If you have found out solution yourself, please share it with the community.

Kautuk Sahni
Level 2
May 16, 2024

@kautuk_sahni  Noop, not yet,. Did try both suggested ways but neither one working.