如何将 log4j 设置为每个错误/警告/信息的特定文件(在 grails 中)
我对 grails 中的 log4j 有点困惑。
我需要将信息记录到 info.log,将错误记录到 error.log,将警告记录到 warning.log(
如果可能),所有文件(信息、警告和错误)都应放入 web-app/ 这样我就可以通过互联网(VPN)进行检查
有人可以帮助我做到这一点吗?
I am little bit confuse about log4j in grails.
I need to log info into info.log, error into error.log and warning into warning.log
if possible, all the files (info,warning and error) should be placed into web-app/
so that i can do check via internet (vpn)
can someone help me to do that ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
假设您使用的是 Grails 1.1+,那么:
使用此配置,
info.log
将包含级别为 INFO 及以上的所有日志消息(即 INFO、WARN、ERROR、FATAL),warn.log
将包含 WARN 及以上内容,error.log
将包含 ERROR 及以上内容。在上面的示例中,我配置了根记录器,因此所有内容(包括 Grails 核心)都会被记录。 当然,如果您愿意,您可以对其进行更细粒度的配置。
希望这可以帮助。
Assuming you are using Grails 1.1+, what about:
With this configuration,
info.log
will contain all log messages with level INFO and above (ie. INFO, WARN, ERROR, FATAL),warn.log
will contain WARN and above,error.log
will contain ERROR and above.In the example above, I have configured the root logger, so everything (including Grails core) gets logged. But of course, you can configure this more fine-grained if you want.
Hope this helps.