Fix potential bug in debug logging. Possibly fixes issue with debug logging not appearing in debug.log.

This commit is contained in:
Jeremy Wood 2012-01-23 13:02:46 -05:00
parent c7d35f13f4
commit 29360feb4e

View File

@ -11,6 +11,9 @@ import java.io.IOException;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.io.StringWriter; import java.io.StringWriter;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.logging.FileHandler; import java.util.logging.FileHandler;
import java.util.logging.Formatter; import java.util.logging.Formatter;
import java.util.logging.Handler; import java.util.logging.Handler;
@ -38,7 +41,9 @@ public class DebugLog {
try { try {
this.fh = new FileHandler(file, true); this.fh = new FileHandler(file, true);
this.log.setUseParentHandlers(false); this.log.setUseParentHandlers(false);
for (Handler handler : this.log.getHandlers()) { List<Handler> handlerList = new ArrayList<Handler>();
handlerList.addAll(Arrays.asList(this.log.getHandlers()));
for (Handler handler : handlerList) {
this.log.removeHandler(handler); this.log.removeHandler(handler);
} }
this.log.addHandler(this.fh); this.log.addHandler(this.fh);