如何设置slf4j来处理HttpServlet中的JUL日志记录? [英] how do I setup slf4j to handle JUL logging in a HttpServlet?

查看:184
本文介绍了如何设置slf4j来处理HttpServlet中的JUL日志记录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个拥有多个HttpServlet的大型现有应用程序. 这些当前是使用log4j日志记录编写的-除了Java.util.logging使用的一些库之外.

We have a large existing app that has several HttpServlets. These are currently written using log4j logging - except a few of the libs that were written with Java.util.logging uses.

我真的很想让它们全部通过log4j处理和输出格式化.

I'd REALLY REALLY like to get them all going through the log4j handling and output formatting.

看来我应该可以使用slf4j来执行此操作-但我找不到有关HOW的任何实际文档.只是很多是的,它可以那样".我已经将slf4j-api.jar,slf4j-log4j12.jar和jul-to = slf4j.jar添加到了我的课程路径中.

It looks like I should be able to use slf4j to do this - but I can't find any actual documentation on HOW. Just lots of "yeah, it can things like that". I've added slf4j-api.jar, slf4j-log4j12.jar and jul-to=slf4j.jar to my class path.

由于这似乎并未处理JUL日志记录(仍然以其自己的格式出现),因此必须做一些特定的事情才能使事情挂起/启动-但我一直无法查找有关所需内容的文档.

Since this doesn't seem to be handling the JUL logging (still coming out in it's own format), there must be something specific that needs to be done to get things hooked up/started - but I haven't been able to find the docs on exactly WHAT is needed.

推荐答案

对于您的问题,您可以使用 http://www.slf4j.org/legacy.html

for your problem, you can use the JUL to SLF4J bridge documented in http://www.slf4j.org/legacy.html

别忘了一次拨打SLF4JBridgeHandler.install()

如果可以的话,我建议您使用迁移器,而不是使用桥接器,这样生成的代码将更干净,性能更好!

If you have the possibility, instead of bridging, I suggest that you use the migrator, resulting code will be cleaner with better performances!

这篇关于如何设置slf4j来处理HttpServlet中的JUL日志记录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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