Announcement Announcement Module
Collapse
No announcement yet.
spring dm server 2.0.0 issue with log4j help!!! Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • spring dm server 2.0.0 issue with log4j help!!!

    Hi guys:

    I am a beginner of Spring dm server. I created two bundles, one is registered as service, the other one simple invoke the service. I used the log4j logger. from the server 2.0.0.M4, I can see it should go to serviceability/logs/bundle name/log.log file.
    however, it always be empty. I didnt see any log4j errors like no appender something.

    when I use spring dm server 1.0, I can see my log4j log msg.
    Reallly weird, I cannot figure out the root cause.

    Could you please help to suggest what I might do stupid wrong
    i dont have any log4j properties, I use the one in dm server /config /serviceability.xml

    If I use system.out, I can see it printed out to the console.

    Thanks
    Feng

  • #2
    seems if I add this to manifest.mf

    Import-Package: org.osgi.framework,org.apache.log4j;bundle-symbolic-name="com.springsource.org.apache.log4j"

    it used the correct log4j package.. but throw no appender info.
    was wondering how I can use the xml defined in ds server/config location,
    or how I can use a customized one.

    Tried to use Class-Path in manifest.mf to include a simple log4j.properties not working properly.

    Comment


    • #3
      finally fixed by giving bundle name for bundle fragement..
      seems I attached to the wrong org.apache.log4j before....

      Manifest-Version: 1.0
      Bundle-ManifestVersion: 2
      Bundle-Name: Config
      Bundle-SymbolicName: log4j.config
      Bundle-Version: 1.0.0.qualifier
      Fragment-Host: com.springsource.org.apache.log4j;bundle-symbolic-name="com.springsource.org.apache.log4j"

      thanks
      guys

      Comment


      • #4
        but seems if I put
        com.springsource.org.apache.log4j-1.2.15.jar
        into usr directory, and my application in pickup,

        this jar no longer get picked up.

        Caused by: com.springsource.kernel.osgi.framework.UnableToSat isfyBundleDependenc
        iesException: Unable to satisfy dependencies of bundle 'log4j.config' at version
        '1.0.0.qualifier': Cannot resolve: log4j.config
        Resolver report:
        Missing constraint: <Fragment-Host: com.springsource.org.apache.log4j; b
        undle-version="0.0.0"> in bundle <log4j.config_1.0.0.qualifier>

        at com.springsource.kernel.install.pipeline.stage.res olve.internal.Quasi
        ResolveStage.process(QuasiResolveStage.java:54)
        at com.springsource.kernel.install.pipeline.internal. StandardPipeline.do
        ProcessTree(StandardPipeline.java:71)
        at com.springsource.kernel.install.pipeline.internal. CompensatingPipelin
        e.doProcessTree(CompensatingPipeline.java:79)
        at com.springsource.kernel.install.pipeline.stage.Abs tractPipelineStage.
        process(AbstractPipelineStage.java:50)
        at com.springsource.kernel.install.pipeline.internal. StandardPipeline.do
        ProcessTree(StandardPipeline.java:71)
        at com.springsource.kernel.install.pipeline.stage.Abs tractPipelineStage.
        process(AbstractPipelineStage.java:50)
        at com.springsource.kernel.deployer.core.internal.Pip elinedApplicationDe
        ployer.performInstall(PipelinedApplicationDeployer .java:268)
        ... 26 more
        [2009-12-18 12:18:45.063] fs-watcher <HD0002E> Hot deploy failed f
        or resource 'C:\springsource-dm-server-2.0.0.M4\pickup\log4j.config_1.0.0.qualif
        ier.jar'.

        Comment


        • #5
          Unless you really want to use Log4J as the logging back end (which, in 2.0, generally won't be necessary as now embed LogBack), you don't need to add the log4j bundle to the repo. Instead you can just use the Log4J to SLF4J bridge that ships with dm Server.

          In your bundle, just import the Log4J packages and proceed as normal. If you app is a standalone bundle, it will generate log output to serviceability/logs/log.log. If your bundle is in a scope, i.e. it's referenced by a scoped plan, or included in a par file, it will generate log output to serviceability/logs/<scope-name>/log.log.

          Comment


          • #6
            Hi Andy

            Thanks for your quick response. I use 2.0.0.M4, didnt use M6 is because I am a beginner. and I deploy all my application in seperate jars as bundles. I will do the PAR in phase 2. so M6 wont print out any log for me since my application is not part of PAR.

            I modified my small test code again:

            activator:


            package testthread;


            import org.apache.log4j.Logger;
            import org.osgi.framework.BundleActivator;
            import org.osgi.framework.BundleContext;

            public class Activator implements BundleActivator {
            private static Logger logger = Logger.getLogger(Activator.class);
            /*
            * (non-Javadoc)
            * @see org.osgi.framework.BundleActivator#start(org.osgi. framework.BundleContext)
            */
            public void start(BundleContext context) throws Exception {
            logger.info("starting thread");
            System.out.println("testing");
            new Thread(new NewThread()).start();


            }

            /*
            * (non-Javadoc)
            * @see org.osgi.framework.BundleActivator#stop(org.osgi.f ramework.BundleContext)
            */
            public void stop(BundleContext context) throws Exception {
            }

            private class NewThread implements Runnable{

            public void run() {
            while(true)
            {
            try {
            Thread.sleep(3000);
            } catch (InterruptedException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            }
            System.out.println("Running");
            logger.info("Running 1");
            }

            }

            }

            }


            manifest file:
            Manifest-Version: 1.0
            Bundle-ManifestVersion: 2
            Bundle-Name: TestThread
            Bundle-SymbolicName: TestThread
            Bundle-Version: 1.0.0.qualifier
            Bundle-Activator: testthread.Activator
            Bundle-ActivationPolicy: lazy
            Bundle-RequiredExecutionEnvironment: J2SE-1.5
            Import-Package: org.osgi.framework;version="1.3.0",org.apache.log4 j


            once I exported, and deployed. except I saw system.out from console,
            the logs generated by logger is empty.

            the log.log file is 0 size.

            Really dont know why. nothing generated if I use org.apache.log4j,

            I have SLF4J-LOG4J jar by default as you said.

            Comment


            • #7
              Also I created the log directory for my simple test class:

              C:\springsource-dm-server-2.0.0.M4\serviceability\logs\TestThread-1.0.0.200912181307

              but log.log is zero all the time.

              Comment


              • #8
                seems it works only if I change all log statements to logger.error()

                logger.info didnt print out anything.. weird

                i didnt touch the config file, it should capture all above DEBUG

                Comment


                • #9
                  The logging configuration in M4 is somewhat confusing. There's a filter in there that makes it harder than it should be to configure logging and enable it at a custom level or for a particular package. I'd recommend moving up to the latest release (RC1 was released today) as it makes this significantly easier, i.e. it works just how you would expect it to work now.

                  Comment

                  Working...
                  X