Time for action – adding logging
The OSGi platform defines a LogService
which allows messages to be logged to a central collector. In the E4 platform, an instance of LogService
is available as part of the platform, routing error messages through to the console.
- Open the
Hello
class and add aprivate
fieldLogService logService
. - Add an
@Inject
annotation to theLogService
field. - In the
create
method, add a call to the log service. - The
Hello
class will look like:import javax.inject.Inject; import org.osgi.service.log.LogService; public class Hello { @Inject private LogService logService; @PostConstruct public void create(Composite parent) { label = new Label(parent, SWT.NONE); label.setText("Hello"); logService.log(LogService.LOG_ERROR, "Hello"); } ...
Get Eclipse Plug-in Development Beginner's Guide - Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.