• <bdo id='zEjAo'></bdo><ul id='zEjAo'></ul>
      <tfoot id='zEjAo'></tfoot>

      <i id='zEjAo'><tr id='zEjAo'><dt id='zEjAo'><q id='zEjAo'><span id='zEjAo'><b id='zEjAo'><form id='zEjAo'><ins id='zEjAo'></ins><ul id='zEjAo'></ul><sub id='zEjAo'></sub></form><legend id='zEjAo'></legend><bdo id='zEjAo'><pre id='zEjAo'><center id='zEjAo'></center></pre></bdo></b><th id='zEjAo'></th></span></q></dt></tr></i><div id='zEjAo'><tfoot id='zEjAo'></tfoot><dl id='zEjAo'><fieldset id='zEjAo'></fieldset></dl></div>

        <legend id='zEjAo'><style id='zEjAo'><dir id='zEjAo'><q id='zEjAo'></q></dir></style></legend>

        <small id='zEjAo'></small><noframes id='zEjAo'>

        Eclipse PDE 日志记录

        时间:2023-08-23

          <small id='SiPf6'></small><noframes id='SiPf6'>

            <tbody id='SiPf6'></tbody>
        1. <i id='SiPf6'><tr id='SiPf6'><dt id='SiPf6'><q id='SiPf6'><span id='SiPf6'><b id='SiPf6'><form id='SiPf6'><ins id='SiPf6'></ins><ul id='SiPf6'></ul><sub id='SiPf6'></sub></form><legend id='SiPf6'></legend><bdo id='SiPf6'><pre id='SiPf6'><center id='SiPf6'></center></pre></bdo></b><th id='SiPf6'></th></span></q></dt></tr></i><div id='SiPf6'><tfoot id='SiPf6'></tfoot><dl id='SiPf6'><fieldset id='SiPf6'></fieldset></dl></div>

            <legend id='SiPf6'><style id='SiPf6'><dir id='SiPf6'><q id='SiPf6'></q></dir></style></legend>
                <bdo id='SiPf6'></bdo><ul id='SiPf6'></ul>
                <tfoot id='SiPf6'></tfoot>

                1. 本文介绍了Eclipse PDE 日志记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我想将插件的异常发送到错误日志,但我不希望它们显示在 Eclipse 控制台中.这就是我正在做的.

                  I want to send the exceptions of my plugin to the Error Log, but I don't want them to be shown in the Eclipse console. This is what I am doing.

                  首先,我实现了 ILogListener.

                  First, I implemented ILogListener.

                  public class MyILogListener implements ILogListener {
                  
                      @Override
                      public void logging(IStatus status, String plugin) {
                          System.out.println("logging: " + plugin);
                  
                      }
                  
                  }
                  

                  我有这个示例动作来做测试.

                  I have this sample Action to do the test.

                  public void run(IAction action) {
                  
                      ILogListener iL = new MyILogListener();
                      Platform.addLogListener(iL);
                  
                      Bundle bundle = Platform.getBundle(test.Activator.PLUGIN_ID);
                      ILog log = Platform.getLog(bundle);
                      Object o = null;
                      try {
                          o.equals("sk");
                      } catch (Exception e) {
                          log.log(new Status(Status.ERROR, test.Activator.PLUGIN_ID, "test", e));
                  
                  
                      }
                  
                  }
                  

                  异常记录在 Eclipse 应用程序的错误日志中,并显示在控制台中.

                  The exception is written in the Error Log of the Eclipse aplication and this is shown in the console.

                  java.lang.NullPointerException
                  at test.actions.SampleAction.run(SampleAction.java:52)
                  at org.eclipse.ui.internal.PluginAction.runWithEvent(PluginAction.java:251)
                  at org.eclipse.ui.internal.WWinPluginAction.runWithEvent(WWinPluginAction.java:229)
                  at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:584)
                  at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:501)
                  at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:411)
                  at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
                  at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1258)
                  at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3588)
                  at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3209)
                  at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2696)
                  at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2660)
                  at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2494)
                  at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:674)
                  at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
                  at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:667)
                  at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
                  at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:123)
                  at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
                  at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
                  at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
                  at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344)
                  at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
                  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
                  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
                  at java.lang.reflect.Method.invoke(Method.java:616)
                  at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622)
                  at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577)
                  at org.eclipse.equinox.launcher.Main.run(Main.java:1410)
                  at org.eclipse.equinox.launcher.Main.main(Main.java:1386)
                  

                  日志记录:org.eclipse.core.runtime

                  logging: org.eclipse.core.runtime

                  您可以看到 MyILogListener 正在打印org.eclipse.core.runtime",我认为它会打印我的插件 ID,即Test".此外,在我的实现中,我没有向日志写入任何内容,但异常出现在错误日志中.我只想在错误日志中写入异常,而不是在控制台中显示.

                  You can see the MyILogListener is printing "org.eclipse.core.runtime", I thought it would print my plugin ID, which is "Test". Also, in my implementation I'm not writing anything to the log, but the exception appears in the Error Log. I only want to write the exception in the Error Log, and not show it in the console.

                  我做错了什么?我正在使用 Eclipse 3.7.0 和 3.7.1 进行尝试.

                  What I am doing wrong? I'm trying this with Eclipse 3.7.0 and 3.7.1.

                  推荐答案

                  根据Eclipse 3.7 文档:

                  所有 Eclipse 日志记录 API 现在都通过名为 org.eclipse.equinox.logger 的 org.eclipse.equinox.log.Logger 进行聚合.所有 ILogListener 实例都将收到通过此记录器记录的条目的通知.

                  All eclipse logging APIs are now aggregated through the org.eclipse.equinox.log.Logger with the name org.eclipse.equinox.logger. All ILogListener instances will be notified of entries logged through this logger.

                  这意味着通过记录到包的日志会通知一堆侦听器,其中一个是 Eclipse StatusManager 将状态记录到错误日志中.

                  This means that by logging to a bundle's log a bunch of listeners will be notified, one of them being Eclipse StatusManager which logs the status to error log.

                  如果您只想记录到 Eclipse 错误日志(和错误日志视图),那么您应该直接调用 StatusManager.handle() 方法之一.

                  If you only want to log to Eclipse error log (and Error Log view) then you should call one of StatusManager.handle() methods directly.

                  这篇关于Eclipse PDE 日志记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:无法完成为 Eclipse 安装 Google 插件 下一篇:如何制作在所有窗口分辨率下显示相似行为(布局)的 SWT/JFace 对话框

                  相关文章

                2. <tfoot id='b15g8'></tfoot>

                        <bdo id='b15g8'></bdo><ul id='b15g8'></ul>

                    1. <legend id='b15g8'><style id='b15g8'><dir id='b15g8'><q id='b15g8'></q></dir></style></legend>
                    2. <i id='b15g8'><tr id='b15g8'><dt id='b15g8'><q id='b15g8'><span id='b15g8'><b id='b15g8'><form id='b15g8'><ins id='b15g8'></ins><ul id='b15g8'></ul><sub id='b15g8'></sub></form><legend id='b15g8'></legend><bdo id='b15g8'><pre id='b15g8'><center id='b15g8'></center></pre></bdo></b><th id='b15g8'></th></span></q></dt></tr></i><div id='b15g8'><tfoot id='b15g8'></tfoot><dl id='b15g8'><fieldset id='b15g8'></fieldset></dl></div>

                      <small id='b15g8'></small><noframes id='b15g8'>