请问log4j的配置如何让日志文件生成的文件显示文件行的序号?谢谢了,分明不够另加
解决方案 »
- jacob word转pdf问题
- 推荐一个“开源”的浏览器,基于eclipse框架开发的
- 想买本JAVA数据结构的书 诚请推荐!
- java提取excel数据以word形式打印??(有哪位高手进来解答一下)
- [求助]如何在java中获得windows系统颜色
- 在crystal report 10.0在IE下的view中无法调出打印按钮??
- 求助,100分求助java绘制曲线的的源代码
- 扑克牌问题
- ◎◎◎◎为什么我的Japplet上的JPopupMenu的MenuItem无法响应??◎◎◎◎◎
- Java中小数运算的问题
- 用java程序写两个方法,分别实现把二维数组转换为ArrayList和把ArrayList转换为二维数组.
- 请问这样的xml文件如何转成类
具体参数记不清了
不知道日志每行的时间可以做行号不
public class CustomConsoleAppender extends ConsoleAppender { private int line = 1; protected void subAppend(LoggingEvent event) {
StringBuffer buffer = new StringBuffer();
buffer.append("[Line:").append(line++).append("]").append(this.layout.format(event));
this.qw.write(buffer.toString()); if(layout.ignoresThrowable()) {
String[] s = event.getThrowableStrRep();
if (s != null) {
int len = s.length;
for(int i = 0; i < len; i++) {
this.qw.write(s[i]);
this.qw.write(Layout.LINE_SEP);
}
}
} if(this.immediateFlush) {
this.qw.flush();
}
}
}
public class CustomPatternLayout extends PatternLayout{
private int line = 1; public String format(LoggingEvent event) {
StringBuffer buffer = new StringBuffer();
buffer.append("[Line:").append(line++).append("]").append(super.format(event));
return buffer.toString();
}}