Like many of us I follow a certain logging scheme. It is a mixture of things I accumulated over time and it does it’s job. My projects usually contain some logging console and I somehow redirect logging output to it.
Recently I’m trying to be a good citizen, meaning that I really try to use existing infrastructure instead of inventing the wheel over and over again. ImageJ2 provides a
LogService – great, so let’s start using it.
You might want to read existing documentation like http://imagej.net/Logging, finding out that the existing ideas seem to make a lot of sense. So let’s find out if they can make me happy.
In order to be happy I’d like to…
- create projects that can run as standalone apps as well as Fiji/ImageJ2 plugins.
- I’d like to display logging information in an
LoggingPanelwhich I can put anywhere in my GUI.
stderrI would like to redirect to the
LoggingPanelas well (don’t wanna miss anything!)
- when running as standalone app (e.g. from Eclipse or from an uber-JAR) I’d like to see all logging on the console too (stdout).
- additionally, could I redirect all logging information in a file ass well – great!
- all this should be conveniently configurable.
Ok, this list does not sound all to crazy I assume many of us have similar requirements. If you think I missed something important, please let me know!!!
After playing for some hours I’ve now put my findings on Github: https://github.com/fjug/IndagoLoggingWrapper
- From within Eclipse: all points I raised above seem to be met.
What does not work:
- As soon as I run from within Fiji things become ugly. The
log4j.propertiesI specify in
resourcesseem not to be used or overwritten by some properties that live in Fiji already. While
I am pretty sure that some/most/all issues my code has in Fiji can be fixed somehow, but here I really need help from someone. So… please help!
A more general question to end this post: if me make my example work, wouldn’t that be something we could use in Fiji (and maybe ImageJ) per default? Every time a plugin writes on
Console pops up which is most of the time simply annoying. (For example it pops up frequently during updates saying “Trying to start the new updater” or something like this. Also it is currently not possible to cut and paste from the
Console. It would be great if it would be replaced by a new console that provides some options menu from where you can (for example)
- specify when the window should open (e.g. stderr output, or log level ERROR, etc.)
- open and edit the
log4j.preferencefile or modify parts of it somehow.
It is clear that this would need someone investing some time, and I would be happy to be this person… but… before I would need to dive deep enough into the existing infrastructure. Obviously I cannot even get my simple logging test (see above) to work as I want within Fiji… so… maybe we do one thing after the other…
Thanks for your thoughts and your help,