将logback.xml放入应用程序中,那些想要自己的logback.xml的人怎么办?
在我的程序中有两种模式:带 GUI 和不带 GUI。当有 GUI 时,所有日志语句都必须发送到 GUI,否则就没有任何意义。没有 GUI 虽然这并不重要。
问题是我预计大多数(75%?)用户会在默认设置的 GUI 模式下使用该程序。我预计其余的用户将需要更高级的日志记录(记录到文件、记录到数据库、根本不记录日志等)。但问题是,如果我迎合 75%,据我所知,这会给其余用户带来痛苦,因为我的 logback.xml 文件是在我的应用程序中提供的。
下一个选项是强制每个人下载默认的 logback.xml 并将其放在应用程序中的某个位置。它增加了灵活性,但这只是设置的另一个部分。此外,我认为告诉大家“你必须将此文件放入你的资源中,否则 GUI 将无法工作”是不好的。应用程序不应该提供一些默认状态吗?
请注意,最后一个选项(有问题地设置所有内容)将不起作用,因为应用程序的其他部分可能会首先加载。例如,一些 Hibernate 代码首先运行,这会在命令行中生成一大堆调试输出。我还认为 GUI 应该显示自应用程序启动以来的所有内容,而不仅仅是从 GUI 加载时开始。
关于我应该做什么有什么建议吗?
In my program there are two modes: With GUI and without a GUI. when there is a GUI, its imperative that all logging statements be sent to the GUI, otherwise there's really no point. Without a GUI though it doesn't really matter.
The issue is that I expect most (75%?) of my users to use the program in GUI mode with default settings. The remaining users I expect will want more advanced logging (logging to a file, logging to a database, no logging at all, etc). The issue though is that if I cater to the 75%, from what I know it will cause pain for the remaining users as my logback.xml file is provided in my application.
The next option would be to force everyone to download the default logback.xml and put it somewhere in their app. It adds flexability, but its just another piece of the setup. Besides, I think its bad to tell everyone "You must put this file in your resources or the GUI won't work". Shouldn't the app provide some default state?
Note that the last option, setup everything problematically, won't work because other parts of the application might load first. For example some Hibernate code runs first which produces a big wall of debug output in the command line. I also think that the GUI should show everything since the application started, not just from the point the GUI loaded.
Any suggestions on what I should do?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我建议提供默认的 logback.xml,然后那些需要更高级配置的人可以使用 -Dlogback.configurationFile=... 指定它
I would suggest providing a default logback.xml, then those who need a more advanced configuration can specify it using -Dlogback.configurationFile=...