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。
查看全文
相关阅读:
二叉树后序遍历
[编程题] 赛马
[编程题] 糖果谜题 C++实现输入未知个整数
[编程题] 时钟
[编程题] 会话列表
A Fast Lock-Free Queue for C++
Design Hangman
Design a URL shortener [转]
ostream 和 ostringsteam 的区别
Hash Table Collision Handling
原文地址:https://www.cnblogs.com/xiziyin/p/1608268.html
最新文章
转载:DNS域名解析全过程
转载:IP地址和子网划分
给一个函数,返回 0 和 1,概率为 p 和 1-p,请你实现一个函数,使得返回 01 概率一样
探讨@GetMapping、@PostMapping和@RequestMapping的区别
解决You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support问题
msf 数据库关联
数字签名伪造工具
windos安全检测常用工具
尝试免杀
tmux 常用操作
热门文章
基于msfrpcd服务编写python的自动测试框架
metasploit的常用模块,永恒之蓝,持久化 清理痕迹
metasploit的安装使用
c++编译后拷贝到其他服务器无法运行
kafka 数据定时删除实验
在Linux上,对于多进程,子进程继承了父进程
NIM问题
好未来笔试
判断链表是否又环
二叉树前序遍历
Copyright © 2011-2022 走看看