Access Logging in Restlet-Spring application

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Access Logging in Restlet-Spring application

Gabriel Falkenberg
Hi,

Is there a way to use the access log functionality in LogService in a
Restlet/Spring application? A minimal Restlet application will log
accesses by default but when I add the Spring integration the access
logging stops. Since Spring seems to use commons-logging by default
I've tried to add SLF4J to direct all logging to Log4J. My pom.xml
contains these dependencies:

        <!-- Logging -->
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.14</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.5.5</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>1.5.5</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>jul-to-slf4j</artifactId>
            <version>1.5.5</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>jcl-over-slf4j</artifactId>
            <version>1.5.5</version>
        </dependency>

And I've installed the SLF4JBridgeHandler by doing:

SLF4JBridgeHandler.install();

When I enable logging via Log4J on debug-level the closest I get to
access logging is:

08-11-11 13:32:37 restlet-spring-logging DEBUG
RestletFrameworkServlet:496 - Successfully completed request
08-11-11 13:32:37 restlet-spring-logging DEBUG
XmlWebApplicationContext:258 - Publishing event in context
[org.springframework.web.context.support.XmlWebApplicationContext@a08f08]:
ServletRequestHandledEvent: url=[/restlet-spring-logging/hello];
client=[127.0.0.1]; method=[GET]; servlet=[Restlet Servlet];
session=[null]; user=[null]; time=[4ms]; status=[OK]

Is this the Spring-integration's default way of handling access
logging? I though I would try to use setLogService(new
LogService(true)) but I think I don't grasp the Component-concept when
working in a servlet-environment. My spring context looks like this:

    <bean id="root" class="com.example.HelloApplication">
        <property name="root" ref="resources"/>
    </bean>

    <bean id="resources" class="org.restlet.ext.spring.SpringRouter">
        <property name="attachments">
            <map>
                <entry key="/hello" value="com.example.HelloResource"/>
            </map>
        </property>
    </bean>

Is a Component implicitly created and how can I access it?

Best Regards
Gabriel Falkenberg
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: Access Logging in Restlet-Spring application

jlouvel
Administrator

Hi Gabriel,

Were you able to solve this logging issue? Do you have sample code to
reproduce the issue?

Otherwise, did you consider other Restlet-Spring integration modes beside
RestletFrameworkServlet? For example, SpringServerServlet might give you
better control on the logging (which will be tunneled to the Servlet logging
channel by the com.noelios.restlet.ext.servlet.ServletLogger adapter class):

User guide - Spring extension:
http://wiki.restlet.org/docs_1.1/13-restlet/28-restlet/70-restlet.html

Best regards,
Jérôme Louvel
--
Restlet ~ Founder and Lead developer ~ http://www.restlet.org
Noelios Technologies ~ Co-founder ~ http://www.noelios.com 

-----Message d'origine-----
De : Gabriel Falkenberg [mailto:[hidden email]]
Envoyé : mardi 11 novembre 2008 13:41
À : [hidden email]
Objet : Access Logging in Restlet-Spring application

Hi,

Is there a way to use the access log functionality in LogService in a
Restlet/Spring application? A minimal Restlet application will log
accesses by default but when I add the Spring integration the access
logging stops. Since Spring seems to use commons-logging by default
I've tried to add SLF4J to direct all logging to Log4J. My pom.xml
contains these dependencies:

        <!-- Logging -->
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.14</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.5.5</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>1.5.5</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>jul-to-slf4j</artifactId>
            <version>1.5.5</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>jcl-over-slf4j</artifactId>
            <version>1.5.5</version>
        </dependency>

And I've installed the SLF4JBridgeHandler by doing:

SLF4JBridgeHandler.install();

When I enable logging via Log4J on debug-level the closest I get to
access logging is:

08-11-11 13:32:37 restlet-spring-logging DEBUG
RestletFrameworkServlet:496 - Successfully completed request
08-11-11 13:32:37 restlet-spring-logging DEBUG
XmlWebApplicationContext:258 - Publishing event in context
[org.springframework.web.context.support.XmlWebApplicationContext@a08f08]:
ServletRequestHandledEvent: url=[/restlet-spring-logging/hello];
client=[127.0.0.1]; method=[GET]; servlet=[Restlet Servlet];
session=[null]; user=[null]; time=[4ms]; status=[OK]

Is this the Spring-integration's default way of handling access
logging? I though I would try to use setLogService(new
LogService(true)) but I think I don't grasp the Component-concept when
working in a servlet-environment. My spring context looks like this:

    <bean id="root" class="com.example.HelloApplication">
        <property name="root" ref="resources"/>
    </bean>

    <bean id="resources" class="org.restlet.ext.spring.SpringRouter">
        <property name="attachments">
            <map>
                <entry key="/hello" value="com.example.HelloResource"/>
            </map>
        </property>
    </bean>

Is a Component implicitly created and how can I access it?

Best Regards
Gabriel Falkenberg

Loading...