Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipse-dev] Logging in Eclipse IDE plug-ins without activator?

For real reference, I updated the FAQ entry.

https://wiki.eclipse.org/FAQ_How_do_I_use_the_platform_logging_facility%3F

On Fri, Aug 23, 2019 at 12:53 PM Lars Vogel <lars.vogel@xxxxxxxxxxx> wrote:
Thanks to Christoph Läubrich for answering in the bug.

For reference here is his example for using a log statement:

public class SampleHandler extends AbstractHandler {

  private static final Bundle BUNDLE =
FrameworkUtil.getBundle(SampleHandler.class);
  private static final ILog LOGGER = Platform.getLog(BUNDLE);

  @Override
  public Object execute(ExecutionEvent event) throws ExecutionException {
    IWorkbenchWindow window =
HandlerUtil.getActiveWorkbenchWindowChecked(event);
    MessageDialog.openInformation(
        window.getShell(),
        "Dsa",
        "Hello, Eclipse world");
    LOGGER.log(new Status(IStatus.INFO, BUNDLE.getSymbolicName(),
"Logging is possible without activator!"));
    return null;
  }
}

On Tue, Aug 20, 2019 at 1:57 PM Lars Vogel <lars.vogel@xxxxxxxxxxx> wrote:
>
> Hi,
>
> what is the recommended way of logging in an Eclipse IDE plug-in these
> days if a plug-in does not have an activator?
>
> I see several implementations in our platform code:
>
> * AbstractUIPlugin#getLog
> * Activator.getDefault().getLogService()
> * InternalPlatform.log
> * org.eclipse.e4.core.services.log.Logger (e4 services)
> * org.eclipse.core.databinding.observable has a Policy class for logging
> * RuntimeLog.log
>
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=502360 had a length
> discussion but no resolution as far as I can tell no preferred way
> emerged from this discussion.
>
> Thomas Watson mentioned that the OSGi LogService has been reworked,
> see https://bugs.eclipse.org/bugs/show_bug.cgi?id=502360#c24. Is using
> this service now the best way to log in plug-in code?
>
> Best regards, Lars
>
> --
> Eclipse Platform project co-lead
> CEO vogella GmbH
>
> Haindaalwisch 17a, 22395 Hamburg
> Amtsgericht Hamburg: HRB 127058
> Geschäftsführer: Lars Vogel, Jennifer Nerlich de Vogel
> USt-IdNr.: DE284122352
> Fax (040) 5247 6322, Email: lars.vogel@xxxxxxxxxxx, Web: http://www.vogella.com



--
Eclipse Platform project co-lead
CEO vogella GmbH

Haindaalwisch 17a, 22395 Hamburg
Amtsgericht Hamburg: HRB 127058
Geschäftsführer: Lars Vogel, Jennifer Nerlich de Vogel
USt-IdNr.: DE284122352
Fax (040) 5247 6322, Email: lars.vogel@xxxxxxxxxxx, Web: http://www.vogella.com
_______________________________________________
eclipse-dev mailing list
eclipse-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/eclipse-dev

Back to the top