如何在 PCFDev 中查看 Tomcat 日志?
How to view Tomcat logs in PCFDev?
我正在 PCFDev 中使用 mysql 部署 2.3.5 Grails 应用程序。在我的应用程序中点击某些 URL 时出现 500 错误。当我使用 cf logs my-sample
查看日志时,我只看到访问日志。他们不显示我的堆栈跟踪。
我怎样才能真正看到日志中的堆栈跟踪,以便我确切知道是什么导致了错误?通常在 Tomcat 中部署应用程序时,我会在 Tomcat 的 /logs
目录中看到这些日志。
这就是我的 config.groovy
的 grails 应用程序的样子。
def catalinaBase = System.properties.getProperty('catalina.base')
if (!catalinaBase) catalinaBase = '.' // just in case
def logDirectory = "${catalinaBase}/logs"
log4j = { root ->
appenders {
// console name: 'stdout', layout: pattern(conversionPattern: "%d [%t] %-5p %c %x - %m%n")
rollingFile name:'stdout', file:"${logDirectory}/my.log".toString(), maxFileSize:'100KB'
rollingFile name:'stacktrace', file:"${logDirectory}/my_stack.log".toString(), maxFileSize:'100KB'
}
warn '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'
debug 'com.aerstone.ldap', 'com.aerstone.scanner.helper'
root.level = org.apache.log4j.Level.INFO
}
谷歌搜索 "cf logs" 调出 http://docs.pivotal.io/pivotalcf/1-8/devguide/deploy-apps/streaming-logs.html as the first result. It has a section on "Writing to the Log from Your App"。它说:
Your app must write logs to STDERR
or STDOUT
. Both are typically buffered, and you should flush the buffer before delivering the message to Loggregator.
除了写入目录或文件外,您还应该考虑根据 Twelve-Factor App treatment of logs.
将该输出发送到 STDOUT
和 STDERR
流
此外,您可以搜索 "cf ssh",其中 this result 解释了如何通过 SSH 连接到应用程序的容器并查看其本地文件系统上的内容。
我正在 PCFDev 中使用 mysql 部署 2.3.5 Grails 应用程序。在我的应用程序中点击某些 URL 时出现 500 错误。当我使用 cf logs my-sample
查看日志时,我只看到访问日志。他们不显示我的堆栈跟踪。
我怎样才能真正看到日志中的堆栈跟踪,以便我确切知道是什么导致了错误?通常在 Tomcat 中部署应用程序时,我会在 Tomcat 的 /logs
目录中看到这些日志。
这就是我的 config.groovy
的 grails 应用程序的样子。
def catalinaBase = System.properties.getProperty('catalina.base')
if (!catalinaBase) catalinaBase = '.' // just in case
def logDirectory = "${catalinaBase}/logs"
log4j = { root ->
appenders {
// console name: 'stdout', layout: pattern(conversionPattern: "%d [%t] %-5p %c %x - %m%n")
rollingFile name:'stdout', file:"${logDirectory}/my.log".toString(), maxFileSize:'100KB'
rollingFile name:'stacktrace', file:"${logDirectory}/my_stack.log".toString(), maxFileSize:'100KB'
}
warn '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'
debug 'com.aerstone.ldap', 'com.aerstone.scanner.helper'
root.level = org.apache.log4j.Level.INFO
}
谷歌搜索 "cf logs" 调出 http://docs.pivotal.io/pivotalcf/1-8/devguide/deploy-apps/streaming-logs.html as the first result. It has a section on "Writing to the Log from Your App"。它说:
Your app must write logs to
STDERR
orSTDOUT
. Both are typically buffered, and you should flush the buffer before delivering the message to Loggregator.
除了写入目录或文件外,您还应该考虑根据 Twelve-Factor App treatment of logs.
将该输出发送到STDOUT
和 STDERR
流
此外,您可以搜索 "cf ssh",其中 this result 解释了如何通过 SSH 连接到应用程序的容器并查看其本地文件系统上的内容。