babyinEclipse
babyinEclipse

Reputation: 513

Logback or Eclipse logger in Eclipse RCP based products

From Eclipse experts I want to know whether it is good to use log framework org.eclipse.e4.core.services.log.Logger provided by Eclipse RCP in RCP based products or shall we use logback in Eclipse RCP? I am using Eclipse E4 for developing. The problem I see with Eclipse logger is it gives warning "Discouraged access: The type 'Logger' is not API". Which one is preferred way of logging in Eclipse RCP development?

Upvotes: 2

Views: 465

Answers (2)

Amos M. Carpenter
Amos M. Carpenter

Reputation: 4958

As @greg-449's answer says, using the org.eclipse.e4.core.services.log.Logger is fine, and the warning can be safely ignored.

For those like me who'd prefer to keep their code free of pesky warnings that shouldn't be warnings, here's how to disable this particular one (same goes for others where you're sure you can safely ignore them).

1) Configure access rules

You can get there either directly from the tooltip shown when hovering over the "Discouraged access" warning...

Configure access rules

... or via your Project properties > Java Build Path > Libraries > Plug-in Dependencies

Project properties

2) Edit the access rules

In the list of plug-in dependencies, find the one that you want to override - in this case, it's the org.eclipse.e4.core.services[version].jar, expand it, click on its access rules, and then on the "Edit..." button on the right.

Edit access rules

3) Add a new rule

Hit the "Add..." button on the right to open the "Add Access Rule" dialog, and add a rule to make org/eclipse/e4/core/services/log/Logger accessible without warnings:

Add access rule

Hit OK to close the dialog.

4) Move the new rule up

The rules are processed top-down until a matching rule is found, so we want the new "Accessible" one to fire before the original "Discouraged" rule. Use the "Up" button to move the new rule, well, up. It should look like this:

New rule added

Accept all the dialogs, and the warnings should be gone.

Upvotes: 1

greg-449
greg-449

Reputation: 111142

Logger is OK despite the discouraged access warning. There are still a number of e4 APIs which have not been completely finalized and these have this warning.

You may also find StatusReporter useful. This can do logging and show error dialogs.

Upvotes: 3

Related Questions