1 16 17 import org.apache.velocity.app.VelocityEngine; 18 import org.apache.velocity.runtime.RuntimeConstants; 19 20 import org.apache.log4j.Category; 21 import org.apache.log4j.BasicConfigurator; 22 23 24 31 public class Log4jCategoryExample 32 { 33 public static String CATEGORY_NAME = "velexample"; 34 35 public static void main( String args[] ) 36 throws Exception 37 { 38 41 42 BasicConfigurator.configure(); 43 44 Category log = Category.getInstance( CATEGORY_NAME ); 45 46 log.info("Hello from Log4jCategoryExample - ready to start velocity"); 47 48 52 53 VelocityEngine ve = new VelocityEngine(); 54 55 ve.setProperty( RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS, 56 "org.apache.velocity.runtime.log.SimpleLog4JLogSystem" ); 57 58 ve.setProperty("runtime.log.logsystem.log4j.category", CATEGORY_NAME); 59 60 ve.init(); 61 62 log.info("this should follow the initialization output from velocity"); 63 } 64 } 65 66 | Popular Tags |