Closed scottmcmaster closed 11 years ago
I'm a bit of a Java logging n00b, so please feel free to submit a pull request with a better way to approach this. I wrote the logging like it is assuming that most people won't be embedding the program and instead will treat it like a simple command line program that gets piped through some more comprehensive logging setup.
I am using browsermob in embedded mode. I have never been able to successfully configure the browserlog logs. If there is a way to do it kindly share.
Yes, I see browsermob most often embedded to work around everybody's favorite WebDriver bug 141. Anyway, hopefully you can do something like this:
new org.browsermob.proxy.util.Log();
InputStream in = null;
try {
in = MyUtilsClass.class.getResourceAsStream("/logging.properties");
LogManager.getLogManager().readConfiguration(in);
} catch (IOException ex) {
System.err.println("WARNING: Logging not configured (console output only)");
} finally {
try { in.close(); } catch (Exception e) {}
}
The sequence of event is: First, force browsermob's Log to statically initialize, during which it blows away any existing logging configuration that may have been set up. Second, explicitly re-read your own logging configuration. It is satisfactory for me, anyway, until I have time to make a better suggestion to Patrick.
Thanks @xskt !!
This is fixed in the primary development line, which is at https://github.com/lightbody/browsermob-proxy. Basically, I removed the static line and moved it in to Main.java, which is where standalone mode runs. So if you're embedding, I no longer do any funky stuff with logging. Hope that helps. If you have more problems, please open a new ticket in that other project. Thanks!
See the static ctor in Log.java. This makes it a little hard to set up, say, a FileHandler in a program that is using Browsermob.