如果用maven,一般你把log4j.properties放在java或者resources下? [英] If using maven, usually you put log4j.properties under java or resources?

查看:45
本文介绍了如果用maven,一般你把log4j.properties放在java或者resources下?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用常规 Maven 目录时,我应该将 log4j.properties 文件放在哪里?

Where should I put the log4j.properties file when using the conventional Maven directories?

推荐答案

src/main/resources 是这个的标准位置".

src/main/resources is the "standard placement" for this.

更新: 以上回答了问题,但不是最佳解决方案.查看其他答案和对此的评论……您可能不会使用 jar 传送自己的日志记录属性,而是将其留给客户端(例如应用程序服务器、阶段环境等)来配置所需的日志记录.因此,将它放在 src/test/resources 中是我的首选解决方案.

Update: The above answers the question, but its not the best solution. Check out the other answers and the comments on this ... you would probably not shipping your own logging properties with the jar but instead leave it to the client (for example app-server, stage environment, etc) to configure the desired logging. Thus, putting it in src/test/resources is my preferred solution.

注意:说到将具体的日志配置留给客户端/用户,您应该考虑在您的应用中将 log4j 替换为 slf4j.

Note: Speaking of leaving the concrete log config to the client/user, you should consider replacing log4j with slf4j in your app.

这篇关于如果用maven,一般你把log4j.properties放在java或者resources下?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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