Log4j Problem Again: How to configure a simple bundle to use Log4j ? [message #82259] |
Wed, 31 January 2007 19:34 |
Eclipse User |
|
|
|
Originally posted by: rubingchiu.yahoo.com.tw
I have reviewed all topics in this forum about using 3rd party jars (especially Log4j), but I did not find a solution to configure a very simple bundle to use Log4j.
The environment is:
1. Eclipse 3.2.1, equinox project
The source codes are:
public class Activator implements BundleActivator {
private Thread m_thread;
public void start(BundleContext context) throws Exception {
if(m_thread == null) {
m_thread = new Thread(new TestClass());
m_thread.setDaemon(false);
m_thread.start();
}
}
public void stop(BundleContext context) throws Exception {
m_thread.interrupt();
m_thread = null;
}
}
The TestClass is:
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
public class TestClass implements Runnable {
public TestClass() {
Logger logger = Logger.getLogger(TestClass.class);
}
public void run() {
int i = 1;
while (i < 1000)
i++;
}
}
}
3. In the META-INF\MANIFEST.MF:
In the tab "Runtime", in the "Classpath", I added "/lib" where Log4.jar existed.
In the tab "build.properties", it is:
source.. = source/
output.. = bin/
bin.includes = META-INF/,\
lib/,\
log4j.properties
src.includes = META-INF/,\
lib/,\
log4j.properties
4. In the project folder, log4j.properties is placed
The problem is:
When I debug this simple bundle, it always terminated at line:
Logger logger = Logger.getLogger(TestClass.class);
Can someone help me?
|
|
|
Re: Log4j Problem Again: How to configure a simple bundle to use Log4j ? [message #82318 is a reply to message #82259] |
Wed, 31 January 2007 20:52 |
Simon Kaegi Messages: 22 Registered: July 2009 |
Junior Member |
|
|
Hi Rubing,
The problem looks like it's in your third step...
> In the tab "Runtime", in the "Classpath", I added "/lib" where Log4.jar
> existed.
You need the full path to your jar e.g.
If you look at the Manifest.mf file itslelf it should contain a line
something like the following:
Bundle-ClassPath: lib/log4j.jar, .
HTH
-Simon
"Rubing Chiu" <rubingchiu@yahoo.com.tw> wrote in message
news:238461.1170272091686.JavaMail.root@cp1.javalobby.org...
>I have reviewed all topics in this forum about using 3rd party jars
>(especially Log4j), but I did not find a solution to configure a very
>simple bundle to use Log4j.
>
> The environment is:
> 1. Eclipse 3.2.1, equinox project
>
> The source codes are:
>
> public class Activator implements BundleActivator {
> private Thread m_thread;
> public void start(BundleContext context) throws Exception {
> if(m_thread == null) {
> m_thread = new Thread(new TestClass());
> m_thread.setDaemon(false);
> m_thread.start();
> }
>
> }
> public void stop(BundleContext context) throws Exception {
> m_thread.interrupt();
> m_thread = null;
> }
> }
>
> The TestClass is:
>
> import org.apache.log4j.Level;
> import org.apache.log4j.Logger;
>
> public class TestClass implements Runnable {
> public TestClass() {
> Logger logger = Logger.getLogger(TestClass.class);
> }
> public void run() {
> int i = 1;
> while (i < 1000)
> i++;
> }
> }
> }
>
> 3. In the META-INF\MANIFEST.MF:
> In the tab "Runtime", in the "Classpath", I added "/lib" where Log4.jar
> existed.
> In the tab "build.properties", it is:
> source.. = source/
> output.. = bin/
> bin.includes = META-INF/,\
> lib/,\
> log4j.properties
> src.includes = META-INF/,\
> lib/,\
> log4j.properties
>
>
>
> 4. In the project folder, log4j.properties is placed
>
> The problem is:
> When I debug this simple bundle, it always terminated at line:
> Logger logger = Logger.getLogger(TestClass.class);
>
>
> Can someone help me?
|
|
|
Powered by
FUDForum. Page generated in 0.03137 seconds