开发者

how to log sites visited by user in grails?

开发者 https://www.devze.com 2023-03-07 01:43 出处:网络
I want to log all sites开发者_JAVA百科 i mean URL\'s visited by user in my app to a file.how to do it with log4j.

I want to log all sites开发者_JAVA百科 i mean URL's visited by user in my app to a file.how to do it with log4j.

With advance thank's Laxmi


Use a filter:

class LogFilters {
   def filters = {
       all(uri: "/**") {
           before = {
               log.info("Controller: ${controllerName}, Action: ${actionName}, Params: ${params}")
           }
       }
   }

}

You can log any variable available to the filter. The full list is here


Alternatively you can configure your application server to log all requests. In Tomcat for example you can configure an AccessLogValve, as described here. http://tomcat.apache.org/tomcat-5.5-doc/config/valve.html

This way you don't have to redeploy.


you can consider using an interceptor to log each page call

0

精彩评论

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