我可以在jsp文件中使用log4j吗?如何在jsp中初始化记录器?
我想在 jsp 文件中使用 log4j 日志框架。
java 文件中 log4j 的典型初始化是:
Logger log = Logger.getLogger(loggedin.class);
如何在 jsp 文件中初始化记录器?这可以做到吗?
I want to use the log4j logging framework in a jsp file.
The typical initialisation of log4j in a java file is:
Logger log = Logger.getLogger(loggedin.class);
How do I initialise the logger in a jsp file? Can this be done?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你可以说
<%Logger LOG= Logger.getLogger(getclass());%>
这将为创建的 jsp 类创建一个记录器。you could say
<%Logger LOG= Logger.getLogger(getclass());%>
this will create a logger for the created jsp class.一般来说,不建议从 JSP 进行日志记录。但如果你真的想这样做,试试这个,
Logger log = Logger.getLogger("loggedin.jsp");
假设JSP 文件名为loggedin.jsp,但您可以给出任何有意义的名称来区分日志详细信息。
Generally speaking logging from JSP is not advisable. But if you really want to do it, try this,
Logger log = Logger.getLogger("loggedin.jsp");
Assuming the JSP file name is loggedin.jsp, but you can give any meaningful name to distinguish the log details.