1

I have a Logger that is listening to a package's log prints and i want that it will ignore one class from the same package. Is it possible?

itzikos
  • 375
  • 1
  • 5
  • 13

2 Answers2

2

You have to create a logging configuration file (i.e logging.properties). It is a properties file that has to contain the following lines:

com.package.level = WARN
com.package.Class.level = ERROR

Of course, you have to replace "package" and "Class" by the ones corresponding to your requirement.

Then, you will have to launch your application as follows:

java -Djava.util.logging.config.file=C:\logging.properties ...

For a complete logging configuration file, check this example.

Guy Bouallet
  • 2,099
  • 11
  • 16
0

If I remember correctly, you can exclude a subpackage as follows. For example, say you want to block com.foo.bar

1) Define logging properties using the mechanisms of your choice. 2) Define a handler at the level of com.foo.bar, and route to something you don't care about (e.g., ConsoleHandler) 3) Set useParentHandlers to false

Because of this, any logging call in com.foo.bar and below will go to the set handler, and will not propagate up to higher levels, so the root logger will not be invoked.

Uri
  • 88,451
  • 51
  • 221
  • 321