使用log4j实现多个日志位置的最佳方法是什么? [英] What is the best way to implement multiple logs location using log4j?

查看:48
本文介绍了使用log4j实现多个日志位置的最佳方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须使用包含多个模块的log4j in out项目来实现多个日志位置,对于每个模块,我必须分别将日志记录在单独的位置

I have to implement multiple log location using log4j in out project which includes multiple modules, for each module i have to log the in separate location

推荐答案

在此处查看我的答案:

Check out my answer here: Log4j to write json array to disk

它显示了如何将com.foo.bar日志发送到控制台,将com.example发送到文件追加器;您可以混合搭配-本质上是log4j.com之后的软件包名称.部分将为根在此处的类的子树创建一个新的记录器;如果在后代程序包中需要更改位置(请记住,默认情况下追加程序是加性的),则必须将'inherit'设置为'false'.

It shows how to send com.foo.bar logs to console, com.example to a file appender; you can mix and match - essentially the package name after the log4j.com. part will create a new logger for the sub tree of classes rooted there; if in a descendant package you need the change the location (remember, appenders are additive by default) you'll have to set 'inherit' to 'false'.

这篇关于使用log4j实现多个日志位置的最佳方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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