I followed another approach: in my main-method I call an initLogging-method which initializes the logging level for each logger with a static constant representing the logging level. The level can easily be changed, just use another enum value and you are done, no other changes required.
The Java util logging API isn't the most developer-friendly This is the code I used:
however, even with your line, I still have some issue with logging: even if turned off at init time, when someone select a file in the browse dialog then the logging in the FileDatabaseManager is outputted.
When I don't select a file in the same dialog, then the logging in the FileDatabaseManager isn't done
in fact I'm seriously considering dumping all logging because of the time I've lost in this turning off business.
I even wrote an example for it:
=> launching it, using the browse dialog to select a file (using the filter on .db file) triggers some logging to be seen afterwards. Using the default filter (all files ok) doesn't trigger this behavior. Feels really buggy and crazy to me...
To be honest: I don't get the problem. When I select a file in your test class I get the following output:
So this line getLogger().info("logger disabled"); is not shown in the console, which is good because you disabled it. Also this line getLogger().info("file selected " + locationField.getText()); produces no output in the console, again a good thing
The other lines in the output are present because you use System.out.println which has nothing to do with java util logging
Joined: Sep 23, 2010
thanks again roel
sorry for the delay, but my 2nd child is born in between, so...
well, happy to read you couldn't reproduce the issue.
On my side, it did happen again with the joined mock file:
startingThread thread main
31 janv. 2011 11:06:37 test.log.LogExample run
INFO: about to disable the log
DatabaseBrowseAction outcome thread AWT-EventQueue-0
31 janv. 2011 11:07:14 test.log.LogExample$1 actionPerformed
INFO: file selected /home/zedros/Bureau/mock.db
closeButton ActionPerformed thread AWT-EventQueue-0
The exact workflow was the following:
- launching the app
- click on the browse button
- selection of the home button then click on desktop
- selection of the joined file
- click on the close button
btw, it only happens when I use the .db filter to choose a .db file. With the other filter it doesn't happen.
I'm a on ubuntu 9.10 (more precisely 2.6.31-22-generic #70-Ubuntu SMP Wed Dec 1 23:51:13 UTC 2010 i686 GNU/Linux), using this java:
java version "1.6.0_20"
OpenJDK Runtime Environment (IcedTea6 1.9.4) (6b20-1.9.4-0ubuntu1~9.10.1)
OpenJDK Server VM (build 19.0-b09, mixed mode)