Page 1 of 2 12 LastLast
Results 1 to 10 of 18

Thread: Logging Problem

  1. #1
    Join Date
    Jun 2009
    Location
    Modena Italy
    Posts
    13

    Default Logging Problem

    Hi,
    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 logger.info 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. #2
    Join Date
    Jun 2009
    Location
    Modena Italy
    Posts
    13

    Default Test

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

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

    Default

    dm-server logging is based on logback. I would highly recommend you read the logback documentation: http://logback.qos.ch/documentation.html

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

    Code:
    <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" />
        </logger>
    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
    Thanks
    Dmitry

  4. #4

    Default

    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" />
    </logger>

    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
    - com.springsource.slf4j.org.apache.commons.logging-1.5.10.jar
    - com.springsource.slf4j.org.apache.log4j-1.5.10.jar

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

    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!

    --erik

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

    Default

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

  6. #6

    Default

    Dmitry,

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

    Regards,
    Erik

  7. #7

    Default

    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 at 03:14 AM.

  8. #8

    Default

    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 at 10:15 AM.

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

    Default

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

  10. #10

    Default

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

Posting Permissions

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