开发者

Configuring Java GAE Appstats for cron job

I configured my web.xml to enable appstats for my cron job. My cron job is handled by a servlet at the URL http://myapp.appspot.com/cron/myjob and executed once an hour.

When I access the appstats admin interface at the URL http://myapp.appspot.com/appstats/stats. I can see stats about /appstats URLs but not about /cron URLs. I was expecting appstats to record events everytime the cron job has been executed. Here is my web.xml:

<web-app>
    <!-- Servlets -->
    <filter>
        <filter-name>guiceFilter</filter-name>
        <filter-class>com.google.inject.servlet.GuiceFilter</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>guiceFilter</filter-name>
        <url-pattern>*</url-pattern>
    </filter-mapping>
    <!-- AppStats -->
    <filter>
        <filter-name>appstats</filter-name>
        <filter-class>com.google.appengine.tools.appstats.AppstatsFilter</filter-class>
        <init-param>
            <param-name>logMessage</param-name>
            <param-value>Appstats available: /appstats/details?time={ID}</param-value>
        </init-param>
    </filter>
    <filter-mapping>
        <filter-name>appstats</filter-name>
        <url-pattern>/cron/*</url-pattern>
    </filter-mapping>
    <!-- AppStats Servlet -->    
    <servlet>
        <servlet-name>appstats</servlet-name>
        <servlet-class>com.google.开发者_StackOverflowappengine.tools.appstats.AppstatsServlet</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>appstats</servlet-name>
        <url-pattern>/appstats/*</url-pattern>
    </servlet-mapping>
<!--     <security-constraint>
        <web-resource-collection>
            <url-pattern>/appstats/*</url-pattern>
        </web-resource-collection>
        <auth-constraint>
            <role-name>admin</role-name>
        </auth-constraint>
    </security-constraint>  -->
    <!-- Default page to serve -->
</web-app>

Solution: I fixed it by putting the AppStats filter before the Guice filter


I fixed it by putting the AppStats filter before the Guice filter

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜