Hi Emmanuel,

Pierre-Arnaud and I already tried that. IIRC it is not so easy, if using
because we are within an OSGi environment. If you use log4j (which is a
bundle itself) it tries to load the log4j.properties, but it can only
access resources within its own classloader, so it can't load the
log4j.properties defined e.g. in a Studio pllugin. There are tricks like
embedding log4j into the plugin or use "buddy class loading" but all not
so nice. Pax-logging also exists. Another idea is to create our own
Logging plugin which provides a logger service.

As we are in Eclipse I'd stick to the log service it provides.

You can create a util class with some convenience methods, see
PluginUtils in schemaeditor plugin as example.

Eclipse 4 introduced a new programming model, where you can just inject
a Logger and it also has more convenient logging methods [1]. But that
migration needs to be done later...

But the most important question: What do you want to achieve? I think
silently logging into a file within a interactive GUI doesn't make too
much sense, right?

Kind Regards,
Stefan

[1] http://www.vogella.com/tutorials/EclipseLogging/article.html#logging



On 01/11/2015 10:04 AM, Emmanuel Lécharny wrote:
> Hi !
> 
> now that I have - again - a working dev platform for Eclipse - many
> thanks Stefan ! - I would like to bring some discussion about logs.
> 
> Currently, we are mostly using the getLog().log() method all over the
> code. It gets the logger from the plugin. So far, so good, but the pb is
> that this approach is only available when you are using it in classes
> inheriting from Plugin.
> 
> One option, as I can see in the code, would be to grab the plugin logger
> like in :
> 
>     ConnectionUIPlugin.getDefault().getLog().log( blah... );
> 
> but it's a bit heavy, and it does not allow you to discriminate between
> errors, warnings or even debug.
> 
> In the LdifModificationLogger, we are using JUL to log LDIF parsing
> error messages. It's very limited to this class.
> 
> All in all, we have very few logs, and the logs we have are mainly
> stacktraces or messages we don't know their level of criticity.
> 
> So, what about using Log4j? Considering that most of the bundles we are
> depending on are using it, why not using it too in Studio ?
> 
> Also what would be the impact, and the technical hurdles we would face
> if so ?
> 
> 
> Wdyt ?
> 
> 

Reply via email to