Dashboard > WG: Programmer's Cafe > ... > Sakai Coding Tips > Using the commons logger
  WG: Programmer's Cafe Log In | Signup View a printable version of the current page.  
  Using the commons logger
Added by Aaron Zeckoski, last edited by Aaron Zeckoski on May 23, 2006  (view change)
Labels: 
(None)

  1. Adding the commons-logger dependency to your project.xml
    1. Add the following to the dependencies block of your project.xml file to include the commons-logger:
      <dependency>
      	<groupId>commons-logging</groupId>
      	<artifactId>commons-logging</artifactId>
      	<version>1.0.4</version>
      </dependency>
      • The commons logger is included in shared/lib by Sakai itself so you do not need to package it in your tool war file (hence there is no <war.bundle>true</war.bundle>)
      • Version 1.0.4 was the current version when this was written
  2. Adding the logger to your code
    1. Add the following line just below your class line:
      private static Log log = LogFactory.getLog(MyClass.class);
      • Make sure your class name is listed in place of MyClass
    2. The commons logger requires 2 imports (eclipse will insert these for you):
      import org.apache.commons.logging.Log;
      import org.apache.commons.logging.LogFactory;

Site running on a free Atlassian Confluence Open Source Project License granted to Sakai Foundation. Evaluate Confluence today.
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.5.5 Build:#811 Jul 25, 2007) - Bug/feature request - Contact Administrators