hello, 


This is my features.xml  :


  <feature name='log6-bundle' version='1.0'>
        
<bundle>file:///C:/Users/xxx/Downloads/apache-karaf-3.0.1/apache-karaf-3.0.1/deploy/bundles/log6/testLoggerVF.jar</bundle>
 </feature>

this is acivator.java 
package com.vogella.osgi.firstbundle.internal.BundleLogV6;

import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;


import org.slf4j.Logger; 
import org.slf4j.LoggerFactory; 

import com.vogella.osgi.firstbundle.internal.BundleLogV6.MyThread;

public class Activator implements BundleActivator {
          private MyThread myThread;
          
          private final static Logger LOGGER =
LoggerFactory.getLogger(Activator.class); 


          public void start(BundleContext context) throws Exception {
            System.out.println("logV6 Starting com.vogella.osgi.firstbundle");
            LOGGER.info("log info : Starting com.vogella.osgi.firstbundle"); 

            myThread = new MyThread();
            myThread.start();
          }

          
          public void stop(BundleContext context) throws Exception {
            System.out.println("Stopping com.vogella.osgi.firstbundle");
            LOGGER.info("log info : Stopping com.vogella.osgi.firstbundle"); 

            myThread.stopThread();
            myThread.join();
          }

} 



and this is MyThread.java

package com.vogella.osgi.firstbundle.internal.BundleLogV6;


import org.slf4j.Logger; 
import org.slf4j.LoggerFactory; 

public class MyThread extends Thread {
          private volatile boolean active = true;

          private final static Logger LOGGER =
LoggerFactory.getLogger(MyThread.class); 

          public void run() {
            while (active) {
              System.out.println("ahoy OSGi console");
              LOGGER.info("Hello man"); 
              LOGGER.info("tetbundlelog v6"); 
              LOGGER.info("My stuff"); 
              try {
                Thread.sleep(5000);
              } catch (Exception e) {
                System.out.println("Thread interrupted " + e.getMessage());
              }
            }
          }

          public void stopThread() {
            active = false;
          }
} 




--
View this message in context: 
http://karaf.922171.n3.nabble.com/logging-and-karaf-how-to-do-it-tp4033438p4033446.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Reply via email to