Skip navigation
Currently Being Moderated

How to create log files and save them on a local folder?

Apr 18, 2012 8:04 PM

Tags: #configuration #log #logger

How can I create multiple log files and save them on a local folder?

I need to create one file for each level(ERROR, INFO, etc.). How do I configure the logger to do this? Thanks.

 
Replies
  • Currently Being Moderated
    Apr 18, 2012 10:26 PM   in reply to phneville

    Hi phneville,

     

    Please follow these steps:

     

    1. In CRXDE, create a new folder named "config" inside /apps/<%YOUR_APP%>.

    2. Inside config, create a new node with:

              Name: org.apache.sling.commons.log.LogManager.factory.config-demo

              Type : sling:OsgiConfig (select from drop down)

    3. Click Finish to save changes.

    4. In CRXDE, select the node apps/<%YOUR_APP%>/config/ org.apache.sling.commons.log.LogManager.factory.config-demo and add the following properties.

        

    Property Name                                                                      Type                                                 Value

     

    org.apache.sling.commons.log.file                                          String                                          ../logs/demo.log

    org.apache.sling.commons.log.level                                        String                                          Debug

    org.apache.sling.commons.log.names                                    String                                          apps.<%YOUR_APP%>

    org.apache.sling.commons.log.pattern                                   String                                           {0,date,dd.MM.yyyy HH:mm:ss.SSS} *{4}* [{2}] {3} {5}

     

    5. Add the log commands to the component file

         Eg: log.debug(“inside filename.jsp”);

     

    6. Run the component.

    7. Navigate to "<%cq-install-directory%>/crx-quickstart/logs‟.

    8. Open the demo.log file to see the log statements

     

     

    And you should be good to go...

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 19, 2012 1:46 AM   in reply to phneville

    In step 4, you have specified "org.apache.sling.commons.log.level" as debug.

     

    Similarly create new nodes for various logging levels.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points