我有一个Grails 2.3.7应用程序。
在Config.groovy中,我添加了-
log4j = {
appenders {
rollingFile name:'stdout', file:"${logDirectory}/myapp.log".toString()
rollingFile name:'stacktrace', file:"${logDirectory}/stacktrace_myapp.log".toString()
appender new org.apache.log4j.net.SocketAppender(name:'central',
layout:pattern(conversionPattern:'%d{ISO8601} %-5p %c{2} %x - %m%n'),
remoteHost: 'localhost', port: 4560, reconnectionDelay: 10000,locationInfo:true)
}
info 'grails.app'
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'
//debug 'org.apache.http.wire'
}
我还安装了Logstash来收听日志消息。 Logstash配置文件文件-
input {
log4j {
mode => "server"
host => "localhost"
port => 4560
type => log4j
}
}
output {
elasticsearch { host => localhost }
stdout { codec => rubydebug }
}
但是我看不到Logstash解析任何日志。也就是说,stdout或elasticsearch接口(interface)上都没有输出。
虽然我可以看到myapp.log文件中正在生成日志
最佳答案
添加线
root { info "central", "stdout", "stacktrace" }
在appenders块完成之后