HOW-TO: Logging in VAP with Jakarta Commons Logging

Commons Logging is a logging library from Jakarta Project that acts like a thin layer between different logging tools. It provides adapters for other popular logging implementations like log4j and JDK 1.4.


DEVELOPING WITH COMMONS LOGGING
(Commons logging general use guide can be found here)

To use commons logging, we should take the following steps:

  1. Include in our project commons logging library (free download) or use the version included in thirdparty-combined.jar library provided by vignette (recommended).
  2. Import org.apache.common.logging.LogFactory and org.apache.common.logging.Log interface into your class.
  3. Initialize a Log interface final and static variable.
  4. Call logging level desired methods: debug, warn, error, fatal, info, ...

It is recommended to enclosure method call inside a conditional check to evaluate if log level is available, to be more efficient, like in the example:

Commons Logging Method Use Example


CONFIGURING COMMONS LOGGING

Configuration changes depending on which implementation we use. Here we can find a basic configuration, or here for an advanced configuration.
(In Apache Tomcat, standard logging output for a basic configuration can usually be found in /logs/catalina.out file).


Configuration in a JSR-168 Portlet

  1. Create a properties file called commons-logging.properties and establish the property org.apache.commons.logging.Log with the name of the logging adapter to be used.
    For example:
    org.apache.commons.logging.Log= org.apache.commons.logging.impl.SimpleLog
  2. If this concrete implementation requires other files, also create them.
    For example:
    SimpleLog implementation needs a simplelog.properties file and it's configuration could be this:
    org.apache.commons.logging.simplelog.defaultlog=warn
    org.apache.commons.logging.simplelog.showShortLogname=true
    org.apache.commons.logging.simplelog.showdatetime=true
    org.apache.commons.logging.simplelog.log.us.mycompany=debug
  3. Include these properties files into folder [<PortletFolder>]/WEB-INF/classes and restart the application.


Configuring in VAP (Vignette Application Portal)

  1. Follow steps 1 and 2 from JSR-168 Portlet configuration.
  2. Add those files into portal/WEB-INF/classes folder and restart the application.

Configuring in DP (Dynamic Portal)

  1. Follow steps 1 and 2 from JSR-168 Portlet configuration.
  2. Add those files into vgn-ext-templating/WEB-INF/classes folder and restart the application.