简体   繁体   中英

Prevent imported libraries from using my logging-configuration file

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 . 前 3 行是我的日志,其余的属于 GraphStream

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:

com.thirdparty.level = OFF

Or alternatively, default everything to OFF and set your packages to DEBUG :

.level = OFF
com.mycompany.level=DEBUG

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM