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:
- Include in our project commons logging library (free download) or use the version included in thirdparty-combined.jar library provided by vignette (recommended).
- Import org.apache.common.logging.LogFactory and org.apache.common.logging.Log interface into your class.
- Initialize a Log interface final and static variable.
- 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:
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
- 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
- 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
- Include these properties files into folder [<PortletFolder>]/WEB-INF/classes and restart the application.
Configuring in VAP (Vignette Application Portal)
- Follow steps 1 and 2 from JSR-168 Portlet configuration.
- Add those files into portal/WEB-INF/classes folder and restart the application.
Configuring in DP (Dynamic Portal)
- Follow steps 1 and 2 from JSR-168 Portlet configuration.
- Add those files into vgn-ext-templating/WEB-INF/classes folder and restart the application.
Bookmark/Search this post with:
Recent comments
4 days 1 hour ago
2 weeks 4 days ago
5 weeks 3 days ago
7 weeks 1 day ago
7 weeks 2 days ago
9 weeks 5 days ago
9 weeks 5 days ago
11 weeks 1 day ago
11 weeks 3 days ago
11 weeks 3 days ago