Hi Takasho,

Thanks for the context, that helps a lot.

You need to create a subclass of
com.noelios.restlet.ext.servlet.ServerServlet that overrides the method
createComponent() with this code:

@Override
public Component createComponent() {
    Component result = super.createComponent();
    result.getLogService().setEnabled(false);
    return result;
}

Then in your web.xml, you make your "RestServlet" servlet point to your
ServerServlet subclass.

That should be all that is necessary.

Best regards,
Jerome


2007/12/20, Takasho <[EMAIL PROTECTED]>:
>
> I will try to illustrate my implementation as best as I
> can then hopefully I can find a way to solve my logging issue.
>
> In my web.xml I have:
>
> <listener>
>   <listener-class>
>     org.springframework.web.context.ContextLoaderListener
>   </listener-class>
> </listener>
>
> <context-param>
>   <param-name>org.restlet.application</param-name>
>   <param-value>org.example.RestApplication</param-value>
> </context-param>
>
> <servlet>
> <servlet-name>RestServlet</servlet-name>
>   <servlet-class>
>     com.noelios.restlet.ext.servlet.ServerServlet
>   </servlet-class>
>   <load-on-startup>0</load-on-startup>
> </servlet>
>
> <servlet-mapping>
>   <servlet-name>RestServlet</servlet-name>
>     <url-pattern>/atom/*</url-pattern>
> </servlet-mapping>
>
> Which initializes the spring framework and also hands all
> /atom/* requests to the ServerServlet.
>
> My RestApplication contains:
>
> public class RestApplication extends Application {
>   public RestApplication(Context context){
>     super(context);
>   }
>
>   @Override
>     public Restlet createRoot() {
>       Router router = new Router(getContext());
>       RestManager manager = (RestManager) SpringResolver.
>         getBean("manager");
>       manager.init(router);
>       return router;
>     }
>     public void handle(Request request, Response response) {
>       try {
>         start();
>       } catch (Exception ee) {
>         ee.printStackTrace();
>       }
>       super.handle(request, response);
>     }
> }
>
> This gets a reference to the RestManager via spring. It
> hands it a map of <String, Restlet> and calls its init
> method.
>
> My RestManager contains:
>
> public class RestManager {
>
>   private Map<String, Restlet> resourceMappings
>     = new HashMap<String, Restlet>();
>   public void init(Router router) {
>     for (String key : resourceMappings.keySet()) {
>       router.attach(key, resourceMappings.get(key));
>     }
>   }
>   public void setResourceMappings(HashMap<String, Restlet>
>     resourceMappings) {
>     this.resourceMappings = resourceMappings;
>   }
> }
>
> This loops over the map and attaches all the restlets
> to the router.
>
> My Spring applicationContext.xml file contains:
>
> <bean id="portalRoot" class="org.example.PortalRoot">
>
> <bean id="manager" class="org.example.RestManager">
>   <property name="resourceMappings">
>     <bean class="java.util.HashMap">
>       <constructor-arg>
>         <map>
>           <entry key="/portal">
>             <ref local="portalRoot" />
>           </entry>
>         </map>
>       </constructor-arg>
>     </bean>
>   </property>
> </bean>
>
> As you can see all the restlets are defined in the map.
>
> PortalRoot contains:
>
> public class PortalRoot extends Restlet {
>
>   public void handle(Request request, Response response) {
>     if (request.getMethod().equals(Method.GET)) {
>       snip........ main code etc......
>
> This handles all my get requests for /atom/portal, I have
> simplified the code to make it easier to read.
>
> I would like to disable logging at the RestApplication level
> see above. Not at the PortalRoot restlet level.
>
> As I am not directly referencing any restlet components I am
> finding it hard to see where to put the logging code.
>
> Thanks,
>
> Takasho
>
>

Reply via email to