1

I am very new to Grails. I uses to work a little bit with Ruby.

I made an iOs app which communicates with the grails backend. Now I have the problem that I can't see what exactly the server receives.

I am searching for the development.log file. Or a way to see what my server receives and sends as well as the logs entries.

I develop in NetBeans IDE 7.1.2 and Grails 2.1.

thx

4

2 回答 2

2

如果您使用 tomcat 作为服务器,只需启用访问日志阀,您将获得包含所有请求的日志:http: //tomcat.apache.org/tomcat-5.5-doc/config/valve.html#Access_Log_Valve

于 2012-07-15T09:40:32.917 回答
0

我正在做一些非常像你正在做的事情。我为移动应用创建了一个单独的日志文件。我将在 Config.groovy 中包含我的整个 log4j 部分,以使其更易于理解。这将创建 4 个附加日志/var/log/grails/- 错误、警告、信息和 mobileApp 日志;根据需要进行更改。

log4j = {
    appenders {
        rollingFile  name:'infoLog', file:'/var/log/grails/info.log', threshold: org.apache.log4j.Level.INFO, maxFileSize:"1MB", maxBackupIndex: 10
        rollingFile  name:'warnLog', file:'/var/log/grails/warn.log', threshold: org.apache.log4j.Level.WARN, maxFileSize:"1MB", maxBackupIndex: 10
        rollingFile  name:'errorLog', file:'/var/log/grails/error.log', threshold: org.apache.log4j.Level.ERROR, maxFileSize:"1MB", maxBackupIndex: 10
        rollingFile  name:'mobileAppLog', file:'/var/log/grails/mobile.log', threshold: org.apache.log4j.Level.INFO, maxFileSize:"1MB", maxBackupIndex: 10
       //UNTESTED
       rollingFile  name:'debugLog', file:'/var/log/grails/debug', threshold: DEBUG, maxFileSize:"1MB", maxBackupIndex: 10
    }
    root {
        info 'infoLog','warnLog','errorLog', stdout
        error()
        additivity = true
    }

    info mobileAppLog: 'mobileAppLog', additivity:false

    error  'org.codehaus.groovy.grails.web.servlet',  //  controllers
           'org.codehaus.groovy.grails.web.pages', //  GSP
           'org.codehaus.groovy.grails.web.sitemesh', //  layouts
           'org.codehaus.groovy.grails.web.mapping.filter', // URL mapping
           'org.codehaus.groovy.grails.web.mapping', // URL mapping
           'org.codehaus.groovy.grails.commons', // core / classloading
           'org.codehaus.groovy.grails.plugins', // plugins
           'org.codehaus.groovy.grails.orm.hibernate', // hibernate integration
           'org.springframework',
           'org.hibernate',
           'net.sf.ehcache.hibernate'

    //UNTESTED - you could remove individual entries here to get less data
    debug 'org.codehaus.groovy.grails.web.servlet',  //  controllers
           'org.codehaus.groovy.grails.web.pages', //  GSP
           'org.codehaus.groovy.grails.web.sitemesh', //  layouts
           'org.codehaus.groovy.grails.web.mapping.filter', // URL mapping
           'org.codehaus.groovy.grails.web.mapping', // URL mapping
           'org.codehaus.groovy.grails.commons', // core / classloading
           'org.codehaus.groovy.grails.plugins', // plugins
           'org.codehaus.groovy.grails.orm.hibernate', // hibernate integration
           'org.springframework',
           'org.hibernate',
           'net.sf.ehcache.hibernate'

    warn   'org.mortbay.log'

    debug "grails.app"
}

然后,当我需要在控制器中使用我的 mobileAppLog 时,请执行以下操作:

import org.apache.log4j.Logger

//inside controller class
def appLog = Logger.getLogger('mobileAppLog')

//To actually write to the log
appLog.info("whatever you need to write")
于 2012-07-13T20:37:31.367 回答