我可以在jsp文件中使用log4j吗?如何在jsp中初始化记录器?

发布于 2024-11-26 21:14:17 字数 155 浏览 1 评论 0原文

我想在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

缱绻入梦 2024-12-03 21:14:17

你可以说 <%Logger LOG= Logger.getLogger(getclass());%> 这将为创建的 jsp 类创建一个记录器。

you could say <%Logger LOG= Logger.getLogger(getclass());%> this will create a logger for the created jsp class.

淡紫姑娘! 2024-12-03 21:14:17

一般来说,不建议从 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文