Page 2 of 2 FirstFirst 12
Results 11 to 18 of 18

Thread: Logging Problem

  1. #11
    Join Date
    Dec 2005
    Location
    Philadelphia, PA, USA
    Posts
    228

    Default

    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.
    Thanks
    Dmitry

  2. #12

    Default

    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.

  3. #13
    Join Date
    Dec 2005
    Location
    Philadelphia, PA, USA
    Posts
    228

    Default

    Ok, you right .

    This is what I did in logback.xml:
    Code:
    <logger level="DEBUG" additivity="false" name="com.log.test">
            <appender-ref ref="STDOUT"/>
            <appender-ref ref="FILE_SERVICE"/>
        </logger>
        <!--<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"/>-->
        <!--</root>-->
    Result in serviceability/logs/log.log and /logs/dm-server/log.log are similar
    Code:
    [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.
    Thanks
    Dmitry

  4. #14

    Default

    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...

  5. #15
    Join Date
    Dec 2005
    Location
    Philadelphia, PA, USA
    Posts
    228

    Default

    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?
    Thanks
    Dmitry

  6. #16

    Default

    I read your previous message, and supposed it would be easy to use custom config.
    Quote Originally Posted by dsklyut View Post
    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.
    Quote Originally Posted by dsklyut View Post
    Is there a reason why you don't want to modify that file?
    Well I would prefer to deploy configuration with my application, without changing Spring DM Server config.

    Nevertheless, thanks for help.

  7. #17

    Default

    I also would prefer to include logging configuration in my application bundles without touching the server's config file, since it's specific to the application.
    I've spend hours on researching until I came across this thread.
    If anyone knows how to deal with this I would appreciate it.

  8. #18

    Default

    Ivan, you can try next steps:

    1. Remove slf4j.nop bundle from repository/ext folder.
    2. Add import of ch.qos.logback.classic and ch.qos.logback.core packages in your's application bundle.
    3. Put logback.xml in bundle classpath of your application's bundle.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •