防止导入的库使用我的日志配置文件
敌意收购我的记录器!
TL:DR Imported Library使用了我的Logger logging.properties 文件。
为了跟踪我项目中发生的一切,我使用java.utils.logging
实现了一个自定义记录器类,并带有一个不错的简单配置文件“ logging.properties ”:
handlers= java.util.logging.ConsoleHandler, java.util.logging.FileHandler
.level= ALL
java.util.logging.FileHandler.pattern = server/java/data/logs/myOwnLog%u.log
java.util.logging.FileHandler.limit = 20000
java.util.logging.FileHandler.count = 10
java.util.logging.FileHandler.formatter = server/java/src/main/java/controller/utils/logs/LineFormat.java
java.util.logging.ConsoleHandler.level = ALL
com.journaldev.files = SEVERE
现在,由于某种原因添加了它后,我导入的库之一 - graphstream
开始使用我的配置文件。
这意味着我将其日志打印到我的控制台上,并将其保存在位置中的日志文件中,并在配置文件中定义的名称。
我以为可能与那里的配置文件有一系列姓名冲突,但不是。
有什么想法吗?
Hostile takeover of my logger !!
TL:DR imported library is using my logger's logging.properties file.
In order to keep track of everything that happens in my project, I implemented a custom logger class using java.utils.logging
, with a nice simple configuration file "logging.properties":
handlers= java.util.logging.ConsoleHandler, java.util.logging.FileHandler
.level= ALL
java.util.logging.FileHandler.pattern = server/java/data/logs/myOwnLog%u.log
java.util.logging.FileHandler.limit = 20000
java.util.logging.FileHandler.count = 10
java.util.logging.FileHandler.formatter = server/java/src/main/java/controller/utils/logs/LineFormat.java
java.util.logging.ConsoleHandler.level = ALL
com.journaldev.files = SEVERE
Now after adding it, for some reason, one of my imported libraries - GraphStream
start to use my configuration file.
Which means I get thier logs printed to my console and saved in log files in the location and with the name I defined in the configuration file.
I thought maybe there was a conflict of names with there configuration file but it wasn't it.
Any ideas?
first 3 lines are my logs and the rest are belongs to GraphStream
.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这就是Java中的日志记录的工作方式:任何东西都可以尝试编写日志,如果您配置了要使用的记录框架,则会收到其消息。
停止查看消息第三方库的方法是通过更改其报告的级别来禁用您的记录配置(或者,除了您自己的课程以外的所有内容)。
我不使用
java.util.logging
,但是通过阅读文档,您似乎可以包含这样的配置行来关闭第三方软件包:或者,或者默认所有内容代码> off ,将软件包设置为
debug
:This is how logging in Java works: anything can attempt to write logs, and if you have configured the logging framework that it's trying to use, you'll get its messages.
The way to stop seeing messages third-party libraries is to disable them in your logging configuration (or, alternatively, disable everything except your own classes) by changing the level at which they report.
I don't use
java.util.logging
, but by reading the docs it appears that you could include a configuration line like this to turn off a third-party package:Or alternatively, default everything to
OFF
and set your packages toDEBUG
: