在jsp页面中使用log4j的正确方法是什么 [英] what is the right way to use log4j within jsp pages

查看:247
本文介绍了在jsp页面中使用log4j的正确方法是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的意思是,我希望记录器名称能够反映source.jsp文件,无论它是包含在另一个文件中还是编译为类或其他内容.

I mean, I want the logger name to reflect the source.jsp file, no matter if it is included in another file or compiled to a class or whatever.

推荐答案

出了什么问题:

Logger logger = Logger.getLogger( "source.jsp" );

当然,您可以在其前面添加一个更好的无歧义前缀.实际上,沿用JSPS.source.jsp的方法会更好,因为您可以为JSPS记录器设置日志记录规则,以后将其应用于所有子记录器.

You can prepend it with a better non-ambiguous prefix, of course. Actually, something along the lines JSPS.source.jsp is better, as you can set up logging rules for JSPS logger, that would later be applied to all sub-loggers.

话虽如此,为什么您需要直接从JSP登录?

Having said this, why do you need to log from JSP directly?

这篇关于在jsp页面中使用log4j的正确方法是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆