Announcement Announcement Module
No announcement yet.
Logging Problem Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Logging Problem

    I'm using Spring dm server 2.0.0 with Spring 3.0.
    I have some problem with log:
    1) If Itry to deploy a plan dm server create the folder of the plan log into $SERVER_HOME/serviceability/log. Instead if I try to deploy some bundle using STS 2.3.0 the server don't create the folder.
    2)The server show only the System.err or the logger.err (using slf4j) the System.out and or logger.debug are completly ignored.
    3)I checked "Tail application trace files into Console View" but the server show only the dm Server log.

    The strange things is that i didn't modify any config files. The User Guide and the Programmer Guide decribe some different behaviour.

  • #2

    I tried to find a solution and I find where is the problem.
    When I write this code:
    Logger logger = LoggerFactory.getLogger(className.getClass());;
    DM server should use this logger of the serviceability.xml file
     <logger level="INFO" additivity="false" name="com.springsource.osgi.medic.eventlog.default">
    	<appender-ref ref="SIFTED_LOG_FILE" />
    	<appender-ref ref="LOG_FILE" />
    instead the unique method to use this code it's to change the initial code in:
    Logger logger = LoggerFactory.getLogger(className.getClass());"com.springsource.osgi.medic.eventlog.default");
    I don't know how to set my server in the right way...


    • #3
      dm-server logging is based on logback. I would highly recommend you read the logback documentation:

      To see log output from your class configure serviceability.xml with one extra logger configuration, i.e.

      <logger level="INFO" additivity="false" name="name.of.package.where.your.class.sits.or.its.parent.package.or.parent.parent.package">
      	<appender-ref ref="SIFTED_LOG_FILE" />
      As for where the log entries will go to by default, it is a little more tricky.
      1. Scoped plan or par archive or web-application (war) will create a subdirectory under SERVER_HOME/serviceability/log. Note: if you have a plan or par that also contains a webapp (war) you will end up with two subdirectories one for plan/par and another for war.
      This is what dm-server calls "per application logging". It only happens for web apps and "Scoped" deployments - because it is the only real way to identify an "application" in OSGi/dm-server world and attach an MDC to the thread.

      2. Unscoped plans or regular bundles will log to SERVER_HOME/serviceability/log/dm-server/log.log by default if you use SIFTED_LOG_FILE.
      No subdirectories are created per bundle - imagine trying to sift through 100's of log files to re-assembly one thread execution spanning multiple bundle calls because of service invocations and such.

      To configure logging you are not limited to serviceability.xml. You can also deploy a logback.xml configuration together with your bundle. I am not sure if that logback.xml must be at the root of the bundle or in META-INF somewhere. I believe it is in the root. Can't remember.

      Hope this is a little clearer than mud


      • #4
        Hi Dmitry,

        Thanks for your information. It helped me much after I had been searching for documentation about how to get my logs into a serviceability log file. The dm server user guide isn't quite detailed, and documents that are more detailed are a bit outdated. The logback framework looks like a very nice framework.

        For some reason I simply overlooked the fact that I have to set the name in the logger element as you pointed out, so when I added:

        <logger level="INFO" additivity="false" name="nl.chess.clearbizz">
        <appender-ref ref="SIFTED_LOG_FILE" />

        to the serviceability.xml file, I got log messages (!).

        Starnge thing is, that after I changed something else in the code/configuration, it doesn't work anymore, and I am already one day trying to find out what's wrong.

        The application code uses log4j 1.2.15.

        In dm server the following bundles are deployed out of the box:
        - com.springsource.slf4j.api-1.5.10.jar
        - com.springsource.slf4j.bridge-1.5.10.jar
        - com.springsource.slf4j.nop-1.5.10.jar

        I had the idea that I have to deploy myself:
        - com.springsource.slf4j.log4j, and

        But I don't get log messages anymore and I simply don't understand why I got them yesterday

        Maybe you can give me the golden hint. Many thanks in advance!



        • #5
          I only tried logging with slf4j in dm-server. I know that it works without a fail
          Commons logging adapter also forwards log messages to the logback configured loggers (i.e. springframework logging).

          If you can, I would advise using slf4j as a logging adapter instead of log4j apis. You also should not deploy log4j bundles. There is already a slf4j-log4j binding deployed.

          I am a bit confused by
          Strange thing is, that after I changed something else in the code/configuration, it doesn't work anymore
          If you could explain what does not work and what kind of changes you are making it might help to diagnose.


          • #6

            Thank you very much for your reply. I found out that my problem was just the fact that I used log level INFO, while the class logged on level DEBUG . So, the subtile change I made was switching the log level.... Reading logback documentation learned me that it is indeed different from log4j. For our own packages I use log level ALL right now.

            I removed the log4j bundle from dm server (I was more a desperate move).



            • #7
              I have an issue with logging. I'm using slf4j with logback implementation.
              I set system properties -Dlogback.configurationFile on spring dm server startup with full path to my custom logback config file (similar to serviceability.xml config).
              After server started log.log file was created in appropriate place, but it was empty. I configured logback to store all messages, including DEBUG, but it did not help.
              I already tried :
              1) put in into classpath of my main bundle
              2) create fragment bundle with config and attach to ch.qos.logback.classic bundle,
              but it was useless.
              How to configure spring dm to use custom config for my application ? What should I do next?
              Last edited by vladimir.glushak; Apr 13th, 2010, 04:14 AM.


              • #8
                I overcame this issue.
                Spring DM server uses slf4j.nop implementation of logging for my bundles. But nop implementation discard logging!!
                I removed appropriate bundle from repository\ext folder and put logback.xml in classpath of my bundle.
                With such modification, it works for me.
                But how can I push slf4j not to use nop implementation for my bundle without changing stuff in system Spring dm server folders.
                Last edited by vladimir.glushak; Apr 13th, 2010, 11:15 AM.


                • #9
                  Have you tried modifying serviceability.xml? Is there some reason why you don't want to do it?

                  You can package your logback.xml in the root of your bundle and com.springsource.osgi.medic code should pick it up.

                  I never had to remove sl4j.noop from the ext for logging to work.


                  • #10
                    Modifying logging configuration in serviceability.xml works fine. But I would prefer to deploy configuration (including logging configuration) with deploying my application.
                    I prepared very simple project that contain only one activator class, which write log messages with slf4j logger. Logback.xml configuration placed in root folder of my bundle. Currently it do not write logs as expected.
                    Can You take a look at attached archive and say what is wrong with it.


                    • #11
                      I think you should place your logback.xml into src/main/resources.

                      You have at the top of the maven project and it will never get included in the jar that maven generates.

                      Give that a try.


                      • #12
                        Well I used Include-Resource option of maven-bundle-plugin to put logback.xml in jar. Unzip jar file from target dir, logback.xml included in it.


                        • #13
                          Ok, you right .

                          This is what I did in logback.xml:
                          <logger level="DEBUG" additivity="false" name="com.log.test">
                                  <appender-ref ref="STDOUT"/>
                                  <appender-ref ref="FILE_SERVICE"/>
                              <!--<root level="DEBUG">-->
                                  <!--&lt;!&ndash; The following level element is not necessary since the &ndash;&gt;-->
                                  <!--&lt;!&ndash; level of the root level is set to DEBUG by default.    &ndash;&gt;-->
                                  <!--&lt;!&ndash;<level value="DEBUG"/>&ndash;&gt;-->
                                  <!--<appender-ref ref="STDOUT"/>-->
                                  <!--<appender-ref ref="FILE_SERVICE"/>-->
                          Result in serviceability/logs/log.log and /logs/dm-server/log.log are similar
                          [2010-04-14 11:22:47.804] fs-watcher                   com.log.test.LogTestActivator                                     Hello world 
                          [2010-04-14 11:22:47.855] start-signalling-1           com.springsource.osgi.medic.eventlog.default                     DE0005I Started bundle 'log-test' version '1.0.0'. 
                          [2010-04-14 11:24:32.963] fs-watcher                   com.springsource.osgi.medic.eventlog.default                     HD0001I Hot deployer processing 'MODIFIED' event for file 'log-test-1.0.0.jar'. 
                          [2010-04-14 11:24:33.061] fs-watcher                   com.springsource.osgi.medic.eventlog.default                     DE0007I Refreshing bundle 'log-test' version '1.0.0'. 
                          [2010-04-14 11:24:33.117] fs-watcher                   com.springsource.osgi.medic.eventlog.default                     DE0010I Stopping bundle 'log-test' version '1.0.0'. 
                          [2010-04-14 11:24:33.118] fs-watcher                   com.log.test.LogTestActivator                                     Goodbye World 
                          [2010-04-14 11:24:33.125] fs-watcher                   com.springsource.osgi.medic.eventlog.default                     DE0011I Stopped bundle 'log-test' version '1.0.0'. 
                          [2010-04-14 11:24:33.506] fs-watcher                   com.springsource.osgi.medic.eventlog.default                     DE0004I Starting bundle 'log-test' version '1.0.0'. 
                          [2010-04-14 11:24:33.510] fs-watcher                   com.log.test.LogTestActivator                                     Hello world 
                          [2010-04-14 11:24:33.516] start-signalling-1           com.springsource.osgi.medic.eventlog.default                     DE0005I Started bundle 'log-test' version '1.0.0'. 
                          [2010-04-14 11:24:33.529] fs-watcher                   com.springsource.osgi.medic.eventlog.default                     DE0008I Refreshed bundle 'log-test' version '1.0.0'.
                          As far as why it is not writing to the file that you want it to write to - not sure. Try to put in a debugger and see.

                          You can do it with a -debug flag for the startup.bat/sh. Debugger will start up on port 8000 by default.

                          Good luck.


                          • #14
                            How I suppose to know, if behavior is incorrect. Logging is working, no exception throws.
                            The only one problem is issue with not using my custom config.
                            I'm not sure if I be able to catch moment of not loading my config even in debug mode...


                            • #15
                              I did not get a chance to debug through the logging code. I noticed that you are logging at the "error" level. dm-server root logger is at the warn level that is the reason I saw log output in the dm-server logs.

                              When tuning down log level in your example code to "info", dm server did not pick up logback.xml from the bundle. I am not so sure now that embedding logback.xml works.

                              I guess the only way is to modify DM_HOME/config/serviceability.xml (this is renamed logback.xml for the whole server) to add your custom configuration there.

                              Is there a reason why you don't want to modify that file?