Documentation


SEARCH

TABLE OF CONTENT

    1. Getting started 2. Basic concepts 3. Request dispatching 4. Context container 5. Dual MVC 6. Component model: 7. Security 8. Configuration 9. Session handling 10. I18n 11. Cache 12. Logging 13. Error handling 14. Advanced Topics 15. API reference

      Tutorials: Frequently Asqued Questions

      See also:


      The Logging facade

      The log facade

      Table of Contents

      What's logging

      The Logging facade provided by the Lion Framework eases you to control the messages logged in your application.
      However, it's important to note that Lion hasn't his own logging implementation since there are really excelents solutions out there. Instead of it, Lion brings a facade as an integrated way to manage logging.

      By default, Lion framework is configured to use log4php, a logging framework for PHP currently undergoing incubation at the Apache Software Foundation, which support a lot of interesting logging capabilities.

      However, the Logging facade has been designed to work against whatever logging framework, so we are not binding our application to a concrete implementation at all

      Configuring the Logging facade

      The lion.ini file (located as part of the lion distribution within the app/lion.ini file) has the following logging configuration by default:

      1. ...
      2.  
      3. ;-------------------------------------
      4. LOGGING DIRECTIVES:
      5. ;-------------------------------------
      6. LOG_ENABLED yes
      7. LOGGER_CLASS "__Log4PhpLogger"
      8. LOG4PHP_CONFIG_FILE "config/log4php.properties"
      9.  
      10. ...

      We can enable or disable the cache by altering the value of LOG_ENABLED directive. Note that you can also point to whatever facade implementation by just setting the LOGGER_CLASS directive.

      As soon as the default lion's logging facade work against log4php, we can configure it by setting the config_log4php.properties file.

      By default, this file contains the following settings:

      1. log4php.appender.default LoggerAppenderFile
      2. log4php.appender.default.file = logs/error.log
      3. log4php.appender.default.layout LoggerLayoutTTCC
      4. log4php.rootLogger DEBUGdefault

      This properties file set a default appender to log against the logs_error.log.
      In the other hand, the logging level has been set to DEBUG, which means that everything will be logged within our application. However, we are able to setup the logging level as desired.

      Logging facade API

      Logging facade provides a main instance to log: The logger

      To retrieve the default logger associated to our application context, we just need to call the __ContextContainer::getLogger() method:

      1. <?php
      2.  
      3.     //get the application default logger:
      4.     $logger __ApplicationContext::getInstance()->getLogger();

      The logger exposes mainly the following methods:

      i.e.

      1. <?php
      2.  
      3.     //get the default application's logger:
      4.     $logger __ApplicationContext::getInstance()->getLogger();
      5.     //log in debug mode:
      6.     $logger->debug('This is a debug message');