Right thanks for the tip. I didn't know it was so simple.<br><br>So basically I've changed now all the calls to log4j loggers to calls to common logging loggers as you explain below (adding jar to path was already done, it's part of the uniprot japi).<br>
<br>I didn't manage yet to configure my application properly using common logging configuration mechanisms (still using log4j config files and calls), but anyway that can come later. The nice thing is that it works out of the box even mixing the frameworks up!<br>
<br>BTW I also went through lots of trouble with jaligner logging (which is java standard library logging) and especially with strange interactions between it and log4j. Hopefully using commons logging will help to solve all that. <br>
<br>Cheers<br><br>Jose<br><br><br><div class="gmail_quote">On 4 August 2010 15:17, Henning Stehr <span dir="ltr"><<a href="mailto:stehr@molgen.mpg.de">stehr@molgen.mpg.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Hi Jose,<br>
<br>
thanks for getting this started. Since we are just at the beginning<br>
with this, I would still pledge to consider using apache-logging<br>
instead of log4j. The thing is that if you use a specific logging<br>
framework in a library (such as owl) you are forcing the application<br>
that is using the library to use the same system. I had lots of<br>
troubles with JAligner because of this. The commons-logging library<br>
detects what the calling application is using and automatically passes<br>
the appropriate messages to it. The usage inside the library is very<br>
similar (though not identical) to log4j: (taken from<br>
<a href="http://commons.apache.org/logging/guide.html" target="_blank">http://commons.apache.org/logging/guide.html</a>)<br>
<br>
1. put commons-logging.jar in the classpath<br>
<br>
2. add the following imports to a class that wants to use logging:<br>
       import org.apache.commons.logging.Log;<br>
       import org.apache.commons.logging.LogFactory;<br>
<br>
3. Obtain the logger object:<br>
      private Log log = LogFactory.getLog(CLASS.class);<br>
<br>
4. log messsages:<br>
    log.fatal(Object message);<br>
    log.error(Object message);<br>
    log.warn(Object message);<br>
    <a href="http://log.info" target="_blank">log.info</a>(Object message);<br>
    log.debug(Object message);<br>
    log.trace(Object message);<br>
<br>
Now, I havn't used this extensively in practice so there may be<br>
reasons against using it that I don't see now. But it seems to me that<br>
there is a real benefit over using a particular implementation. If it<br>
works as promised it should only be necessary to change a few lines in<br>
the OWL classes that use logging and it should automatically work with<br>
any calling application, no matter what logging framework is being<br>
used there.<br>
<br>
You are right that it can probably be changed easily in the future, so<br>
there is no pressure to change now but I think it's worth considering<br>
at an early rather than late stage :)<br>
<br>
Cheers,<br>
<font color="#888888">Henning<br>
</font><div><div></div><div class="h5"><br>
<br>
On Wed, Aug 4, 2010 at 2:45 PM, Jose M. Duarte <<a href="mailto:jose.m.duarte@gmail.com">jose.m.duarte@gmail.com</a>> wrote:<br>
> Yes for the program I'm developing (for bio vs crystal contacts<br>
> identification) I needed some proper logging. That's why I decided to give a<br>
> go to one of the logging frameworks.<br>
><br>
> First I tried the logging from the standard java library but I was not very<br>
> happy with it. Then I went for log4j which as usual with apache things is a<br>
> lot better.<br>
><br>
> Now I did see this apache commons logging thing, it seems like a meta<br>
> logging framework to use different frameworks underneath. But to be honest<br>
> it fell a bit like an overkill. I know in the long-run is probably not, but<br>
> at that point I couldn't be bothered. Anyway the implementation change<br>
> shouldn't be very difficult if we want to do it. The real difficult thing<br>
> with logging is the logging itself! what messages to write, which level to<br>
> put them in etc. After some experience using it I've realised it really is<br>
> not easy!<br>
><br>
> Anyway I definitely recommend it, the basic usage really is very simple, all<br>
> you need is to declare this constant in your class:<br>
><br>
> private static final Logger LOGGER = Logger.getLogger(UniprotEntry.class);<br>
><br>
> and then you use it like:<br>
><br>
> LOGGER.error("An error happened");<br>
> LOGGER.fatal("A real bad error");<br>
><br>
> Jose<br>
><br>
><br>
> On 4 August 2010 14:38, Henning Stehr <<a href="mailto:stehr@molgen.mpg.de">stehr@molgen.mpg.de</a>> wrote:<br>
>><br>
>> Hi Jose,<br>
>><br>
>> I just looked through the history of OWL. The package is really<br>
>> getting more and more powerful. Great work. I saw that you also<br>
>> started to use logging which I think is really a good idea. I'm not<br>
>> sure which implementation you used but may I suggest to use the apache<br>
>> commons-logging? It looks almost like log4j but it is in fact just an<br>
>> adapter that can be used with different logging implementations in the<br>
>> calling application. This way we don't restrict ourselves to any of<br>
>> log4j/java logging/etc...<br>
>><br>
>> Cheers,<br>
>> Henning<br>
>><br>
>> _______________________________________________<br>
>> Owl-devel mailing list<br>
>> <a href="mailto:Owl-devel@bioinformatics.org">Owl-devel@bioinformatics.org</a><br>
>> <a href="http://www.bioinformatics.org/mailman/listinfo/owl-devel" target="_blank">http://www.bioinformatics.org/mailman/listinfo/owl-devel</a><br>
><br>
><br>
</div></div></blockquote></div><br>