zoukankan
html css js c++ java
让velocity使用log4j
捣鼓一下,水贴下代码。看了就明白了。
Code
1
package
velocity;
2
import
log4j.Log4jDemo;
3
import
org.apache.log4j.BasicConfigurator;
4
import
org.apache.log4j.Logger;
5
import
org.apache.log4j.PropertyConfigurator;
6
import
org.apache.velocity.app.VelocityEngine;
7
import
org.apache.velocity.runtime.RuntimeConstants;
8
public
class
VelocityLogDemo
{
9
public
static
String LOGGER_NAME
=
"
velexample
"
;
10
public
static
void
main(String[] args)
throws
Exception
{
11
PropertyConfigurator.configure(
"
src/main/java/velocity/log4j.properties
"
);
12
//
BasicConfigurator.configure();
13
Logger log
=
Logger.getLogger( LOGGER_NAME );
14
log.info(
"
Log4jLoggerExample: ready to start velocity
"
);
15
VelocityEngine ve
=
new
VelocityEngine();
16
ve.setProperty( RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS,
17
"
org.apache.velocity.runtime.log.Log4JLogChute
"
);
18
ve.setProperty(
"
runtime.log.logsystem.log4j.logger
"
,
19
LOGGER_NAME);
20
ve.init();
21
//
Velocity.init("src/main/java/velocity/velocity.properties");
22
}
23
}
最重要的地方就在于log4j的logger Name,如果没有这个log,那么velocity就无法找到打印的target。
查看全文
相关阅读:
JQuery的摸索之路(一)
C#操作excel(NPOI篇)
Mschart学习(MSchart介绍)
JQuery的摸索之路(二比较)
Mschart学习(开篇)
Mschart学习(官方demo共享)
SQL进阶提升(疑惑篇order by)学习sql server2005 step by step(十一)
一步一步学习C#(二C#基础)
NickLee的学习
Linux 命令学习一
原文地址:https://www.cnblogs.com/xiziyin/p/1608268.html
最新文章
ReportService怎么了?
我的小玩艺
ORACLE SEQUENCE的简单介绍(自增长字段)
EXT扩展实例:在EXT4中检测Iframe的加载事件,并给它加上MASK
在javascript中方便的使用Dictionary实现键值对应
C#中使用ListView动态添加数据不闪烁
EXT扩展实例:在FieldSet上添加一个关闭按钮
javascript中json和string互相转换
在Repeater中使用DropDownList的方法
Winform程序获取路径可以按以下方式
热门文章
字符转换(2,8,10,16进制,ASCII码)
新开通的博客专注 前台js与报表应用
正则 取出url中的数值
CSS控制,文字反转过来
Window7操作系统下IIS配置部署Asp.net
ExtJs中获得(GridPanel)选中的当前选中行号
Ext 中带有tbar按钮右侧对齐方法
form.getForm().submit的用法及Ext.Ajax.request的小小区别
RDLC报表应用之Subreport (传递Parameter and ReportDataSource)
C#操作excel(上路篇)
Copyright © 2011-2022 走看看