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

Thread: How to setup logging?

  1. #1
    Join Date
    Oct 2008
    Posts
    0

    Default How to setup logging?

    -Dlog4j.configuration jvm option didn't help

    Also I noticed strange thing - even if I specify import:
    org.apache.log4j;version="1.2.15", really used version is : lib/com.springsource.slf4j.org.apache.log4j-1.5.0.jar

    1. How to configure log4j?
    2. Is it possible to use platform logging capabilities from: com.springsource.platform.serviceability.* ?
    I'm confused that those bundles don't export anything..

    Olex

  2. #2
    Join Date
    Jan 2006
    Location
    Zürich, Switzerland
    Posts
    423

    Default How to setup logging?

    Hi Olex,

    1. To configure trace levels both globally and on a per-application basis, check out the configuration chapter of the User Guide here:

    http://static.springsource.com/projects/s2ap/1.0.x/user-guide/html/ch06.html

    2. Yes, the S2AP automatically routes log statements on a per-application basis to the PLATFORM_HOME/serviceability/trace directory. For more information on application trace files, check out chapter 4 of the User Guide here:

    http://static.springsource.com/projects/s2ap/1.0.x/user-guide/html/ch04s02.html

    Best regards,

    Sam

  3. #3
    Join Date
    Oct 2008
    Posts
    0

    Default How to setup logging?

    So what is the proper way to do logging in your code in an application that runs on the SpringSource AP? Just try to use log4j as usual?

  4. #4
    Join Date
    Jan 2006
    Location
    Zürich, Switzerland
    Posts
    423

    Default How to setup logging?

    Hi Eric,

    > So what is the proper way to do logging in your code in an application
    > that runs on the SpringSource AP? Just try to use log4j as usual?

    Yes, that's correct: use log4j as your normally would. Note, however, that log levels are configured as described in the User Guide here:

    http://static.springsource.com/projects/s2ap/1.0.x/user-guide/html/ch04s02.html

    Regards,

    Sam

  5. #5
    Join Date
    Oct 2008
    Posts
    0

    Default How to setup logging?

    A common log4j file would look like:

    <?xml version="1.0" encoding="UTF-8" ?>
    <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">

    <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">

    <appender name="appender" class="org.apache.log4j.FileAppender">
    <param name="File" value="identity.log"/>
    <param name="Append" value="false"/>
    <layout class="org.apache.log4j.PatternLayout">
    <param name="ConversionPattern" value="%d [%t] %p - %m%n"/>
    </layout>
    </appender>

    <category name="foo.bar">
    <priority value="debug"/>
    <appender-ref ref="appender"/>
    </category>

    <root>
    <priority value ="debug"/>
    <appender-ref ref="appender"/>
    </root>

    The log4j.xml file is deployed with my web bundle and located in the WEB-INF/classes.

    The problem is that the identity.log is not being created.

    Any idea why ???

  6. #6
    Join Date
    Jan 2006
    Location
    Zürich, Switzerland
    Posts
    423

    Default How to setup logging?

    Hi Thorsten,

    When I said "use log4j as your normally would", I may have been a little vague. What I meant is that you will programatically use log4j the same as you normally would, in terms of obtaining a logger in your classes, etc.; however, the configuration for log4j on the Platform is different in that it is global.

    > The problem is that the identity.log is not being created.

    That's correct. Your log4j log output is being routed to a file such as $PLATFORM_HOME/serviceability/trace/com.myapp-1/trace.log. In addition, your log4j.xml file will not be processed on the S2AP. Instead, you will need to configure this globally as explained in the "Per-application trace" section of the User Guide:

    SpringSource Application Platform uses SLF4J-based implementations of both Commons Logging and Log4J to route output generated by applications using those APIs to its trace files. In addition to appending such output to the global trace.log it will also append it to an application-specific trace file.

    SpringSource Application Platform writes application-specific trace to a file in a subdirectory of the configured trace directory. As described above this directory is, by default, $PLATFORM_HOME/serviceability/trace. The subdirectory's name is of the form <application-name>-<version>. So, for example, an application named com.myapp at version 1 will write its trace to a file in $PLATFORM_HOME/serviceability/trace/com.myapp-1/.

    Regards,

    Sam

  7. #7
    Join Date
    Jun 2009
    Posts
    5

    Default

    I was trying to use per-application tracing with apache commons logging. Each of my applications has their own folder and respective trace file under the serviceability/trace folder. What does not work is that the log statements from the application do not go to the per-application trace files.
    They show up on the console in Eclipse when I run it from there as well as in the global trace.log file. Do I need to do anything special to get the log statements to appear in the per application trace.log files?

  8. #8
    Join Date
    Oct 2008
    Posts
    493

    Default

    To make use of dm Server's per-application tracing, you need to make use of the SLF4J version of commons logging so that your calls via the commons logging API are passed into dm Server's serviceability component.

    How are you importing the commons logging package(s)? I'd recommend using Import-Package as this should ensure that you get wired to the SLF4J-based version of the packages.
    Andy Wilkinson
    SpringSource

  9. #9
    Join Date
    Jun 2009
    Posts
    5

    Default

    I am using the following code to import and use apache commons logging -

    import org.apache.commons.logging.Log;
    import org.apache.commons.logging.LogFactory;

    private static final Log log = LogFactory.getLog(foo.class);

    Subsequently in a method -

    log.error("Retrieving descendents....>");

    org.apache.commons.logging is also added as a dependency to my application.

  10. #10
    Join Date
    Oct 2008
    Posts
    493

    Default

    Sorry, I should have been clearer in my question above. I'm interested to know how you're importing the commons logging package in your manifest, rather than in your code. Could you post the manifest of the bundle in which you're using Commons Logging, please?
    Andy Wilkinson
    SpringSource

Posting Permissions

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