I have a Grails 2.3.7 app.
In Config.groovy I have added -
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'
}
I have also installed Logstash to listen to the log messages. logstash conf. file -
input {
log4j {
mode => "server"
host => "localhost"
port => 4560
type => log4j
}
}
output {
elasticsearch { host => localhost }
stdout { codec => rubydebug }
}
But I do not see any logs being parsed by logstash. That is, there is no output on either stdout or the elasticsearch interface.
localhost:9200/_search?pretty
Though I am able to see logs being generated in myapp.log file
Adding the line
root { info "central", "stdout", "stacktrace" }
after the appenders block did the trick
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.