1

私はGrailsに非常に慣れていません。私はRubyを少し使っていました。

grails バックエンドと通信する iOS アプリを作成しました。今、サーバーが正確に何を受信するかがわからないという問題があります。

development.log ファイルを探しています。または、サーバーが送受信するものとログエントリを確認する方法。

NetBeans IDE 7.1.2 と Grails 2.1 で開発しています。

どうも

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

私はあなたがやっているのと非常によく似たことをしています。モバイル アプリ専用の別のログ ファイルを作成しました。わかりやすくするために、log4j セクション全体を Config.groovy に含めます。これにより/var/log/grails/、エラー、警告、情報、および mobileApp ログの 4 つのアペンダー ログが作成されます。必要に応じて変更してください。

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 に答える