Using the commons logger
- Using the Apache commons logger is the recommended way to do logging in Sakai tools
- Adding the commons-logger dependency to your project.xml
- 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
- Add the following to the dependencies block of your project.xml file to include the commons-logger:
- Adding the logger to your code
- 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
- The commons logger requires 2 imports (eclipse will insert these for you):
import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory;
- Add the following line just below your class line: