javaaem

Getting Dependency Issues and How to Create a Logger File for Specific Classes in AEM?


enter image description hereI'm currently facing difficulties adding logger files for a specific Java class in AEM, and I'm unable to obtain the logger object due to missing dependencies. I'm uncertain about the appropriate steps to resolve this within the AEM environment. Can you guide me on how to correctly configure the logger for a specific class, considering the issue with missing logger object dependency?


Solution

  • Follow the following steps

    1. Check if the required dependencies are included in your Maven pom.xml file. If any dependencies are missing, you can add them to ensure the proper functioning of your project.

    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>{slf4j-version}</version> 
    </dependency>
    

    2. Import the package

    import org.slf4j.Logger;

    3. Provide proper syntax for logger object creation

    private static final Logger logger = LoggerFactory.getLogger(YourClass.class);

    4. Access the LogSupport page in your web console by navigating to http://localhost:4502/system/console/slinglog.

    You can directly inspect the log files in the crx-quickstart/logs directory to view all the logger files present. You can use a text editor or command-line tools to access these logs. Once you locate your logger's created file, you can open it to view the logger messages.