如何在eclipse rcp中使用log4j [英] How to use log4j in eclipse rcp

查看:186
本文介绍了如何在eclipse rcp中使用log4j的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在eclipse rcp项目中使用log4j logging API?作为一种解决方法,我试图创建一个新的OSGI捆绑包,它有一个log4j jar,下面是捆绑结构。

how to use log4j logging API in an eclipse rcp project ?? As a workaround i tried to create a new OSGI Bundle which has a log4j jars,below is the bundle structure.

RCP应用程序

>(template)命名为 loggingtest 。我将log4j包含在loggingtest project的依赖选项卡中。在Activator start方法中,我放置了以下代码

I've crated a basic RCP application with a view(template) named loggingtest.I've included the bundle log4j in the dependencies tab of loggingtest project.In the Activator start method i placed the following code

Logger logger = Logger.getLogger(Activator.class);
logger.info("Info starting");
logger.warn("Warning starting");
logger.error("Error starting");

所以一切都很好,我可以使用log4j API和一半的方式,我是困惑在哪里放置log4j.properties文件,我如何进一步继续获取一个日志文件与所有日志语句。

so everything is fine so far I'm able to use log4j API and half way through,i was puzzled as where to place the log4j.properties file,how can i proceed further to get a log file with all log statements.

下面更精确的是我的清单文件loggingtest项目

to be more precise below is the content of my manifest file of loggingtest project

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: LoggingTest
Bundle-SymbolicName: LoggingTest; singleton:=true
Bundle-Version: 1.0.0.qualifier
Bundle-Activator: loggingtest.Activator
Require-Bundle: org.eclipse.ui,
 org.eclipse.core.runtime,
 log4j;bundle-version="1.0.0"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6


推荐答案

有一个发布如何在OSGi环境中设置Log4J。另请考虑在使用OSGi时使用Pax Logging。

There is a posting how-to setup Log4J in an OSGi-Environment. Also consider using Pax Logging when working with OSGi.

这篇关于如何在eclipse rcp中使用log4j的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆