- 论坛徽章:
- 0
|
[代码] Log4jCategoryExample.java- import org.apache.log4j.BasicConfigurator;
- import org.apache.log4j.Category;
- import org.apache.velocity.app.VelocityEngine;
- import org.apache.velocity.runtime.RuntimeConstants;
- public class Log4jCategoryExample
- {
- public static String CATEGORY_NAME = "velexample";
- public static void main( String args[] )
- throws Exception
- {
- //configure log4j to log to console
- BasicConfigurator.configure();
- Category log = Category.getInstance( CATEGORY_NAME );
- log.info("Hello from Log4jCategoryExample - ready to start velocity");
- VelocityEngine ve = new VelocityEngine();
- ve.setProperty( RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS,
- "org.apache.velocity.runtime.log.SimpleLog4JLogSystem" );
- ve.setProperty("runtime.log.logsystem.log4j.category", CATEGORY_NAME);
- ve.init();
- log.info("this should follow the initialization output from velocity");
- }
- }
复制代码 |
|