0

我正在使用 Grails 版本 2.2.4,并且我已经安装了 kickstart 插件作为编译“:kickstart-with-bootstrap:0.9.6”。

BuildConfig.groovy
plugins {
        runtime ":hibernate:$grailsVersion"
        runtime ":jquery:1.8.3"
        runtime ":resources:1.1.6"

        compile ":kickstart-with-bootstrap:0.9.6"
        build ":tomcat:$grailsVersion"

        runtime ":database-migration:1.3.2"

        compile ':cache:1.0.1'
}

我找到了具有以下目录结构的“KickstartFilters.groovy”过滤器

plugin
  -> kickstart-with-bootstrap:0.9.6
     -> conf
         -> kickstart
             -> KickstartFilters.groovy

我的“KickstartFilters.groovy”文件包含以下信息

package kickstart

class KickstartFilters {

    def filters = {
        all() {
            before = {
                // Small "logging" filter for controller & actions
                log.info(!params.controller ? '/: ' + params : params.controller +"."+(params.action ?: "index")+": "+params)
            }
            after = {
            }
            afterView = {
            }
        }
    }
}

虽然 log.info 打印在日志中,如果密码作为参数传递,那么密码信息在日志中可见,那么我怎样才能只防止密码信息?

4

1 回答 1

0

我有一个解决这个...

https://github.com/joergrech/KickstartWithBootstrap/issues/84

基本上在 conf/kickstart/YourAppFilters.groovy 下创建你的过滤器

包启动

class YourAppFilters  extends KickstartFilters { 
    def filters = {


        kickstartLogger() { 
            before = {
                // Small "logging" filter for controller & actions
                if (log.infoEnabled) {
                    if (!params.controller.equals('chat')) {
                        if (!params.password ) { 
                            log.info(!params.controller ? '/: ' + params : params.controller +"."+(params.action ?: "index")+": "+params)
                        }else{
                            log.info (params.controller+","+params.action+":"+params?.username)
                        }
                    }       
                }
            }
        }
    }
}

现在在 conf/spring/resources.groovy 下的 beans 添加:

yourAppFilters(KickstartFilters)

这现在应该覆盖 kickstarts 过滤器

于 2014-12-04T15:12:09.460 回答