我在 stackoverflow 上的第一个问题 :) 我有一个 e4 rcp 应用程序和日志,就像本教程中描述的那样:Eclipse Logging
@Inject Logger logger;
logger.error("Error: Closing application");
因此,对于我的应用程序,我想在自定义视图中显示日志,但我不知道如何获取日志输出。有没有办法添加一个监听器或其他东西来捕获所有日志信息并将其写入文本字段?
到目前为止感谢您的帮助
我在 stackoverflow 上的第一个问题 :) 我有一个 e4 rcp 应用程序和日志,就像本教程中描述的那样:Eclipse Logging
@Inject Logger logger;
logger.error("Error: Closing application");
因此,对于我的应用程序,我想在自定义视图中显示日志,但我不知道如何获取日志输出。有没有办法添加一个监听器或其他东西来捕获所有日志信息并将其写入文本字段?
到目前为止感谢您的帮助
你可以编写自己的类扩展Logger
来做你想做的事。然后将该类安装到应用程序上下文中以替换默认值。最好的@PostContextCreate
方法是在LifeCycle
类的方法中:
@PostContextCreate
void postContextCreate(IEclipseContext context)
{
Logger myClass = ContextInjectionFactory.make(MyLoggerClass.class, context);
context.set(Logger.class, myClass);
}
LifeCycle
这里描述了类