Here is an example of my Config.groovy based on an article by Burt Beckwith
mail.error.server = 'smtp.yandex.ru'
mail.error.port = 465
mail.error.username = 'do.not.reply@example.com'
mail.error.password = 'site email password'
mail.error.to = 'admin.email@gmail.com'
mail.error.from = "${appName} <${mail.error.username}>"
mail.error.subject = "[Application Error] ${appName} on ${grails.serverURL}"
mail.error.starttls = true
mail.error.protocol = 'smtps'
mail.error.debug = false
mail.error.bufferSize = 512
log4j = {
appenders {
appender new ConsoleAppender(name: 'stdout',
threshold: Level.TRACE,
layout: simple)
appender new RollingFileAppender(name: 'main',
threshold: Level.TRACE,
layout: pattern(conversionPattern: '%d %c{2} %-5p %m%n'),
file: "/var/log/${appName}/main.log",
maxFileSize: 1024
)
System.setProperty 'mail.smtp.port', config.mail.error.port.toString()
System.setProperty 'mail.smtp.starttls.enable', config.mail.error.starttls.toString()
appender new SMTPAppender(name: 'smtp',
threshold: Level.INFO,
layout: pattern(conversionPattern: '%d{[ dd.MM.yyyy HH:mm:ss.SSS]} [%t] %n%-5p %n%c %n%C %n %x %n %m%n'),
to: config.mail.error.to,
from: config.mail.error.from,
subject: config.mail.error.subject,
SMTPHost: config.mail.error.server,
SMTPUsername: config.mail.error.username,
SMTPDebug: config.mail.error.debug.toString(),
SMTPPassword: config.mail.error.password,
SMTPProtocol: config.mail.error.protocol,
bufferSize: config.mail.error.bufferSize
)
}
all 'grails.app'
info 'grails.app.conf',
'grails.app.filters',
'grails.app.taglib',
'grails.app.services',
'grails.app.controllers',
'grails.app.domain'
error 'org.codehaus.groovy.grails.web.servlet',
'org.codehaus.groovy.grails.web',
'org.codehaus.groovy.grails.web.pages',
'org.codehaus.groovy.grails.web.sitemesh',
'org.codehaus.groovy.grails.web.mapping.filter',
'org.codehaus.groovy.grails.web.mapping',
'org.codehaus.groovy.grails.commons',
'org.codehaus.groovy.grails.plugins',
'org.codehaus.groovy.grails.orm.hibernate',
'org.springframework',
'org.hibernate',
'net.sf.ehcache.hibernate'
trace 'org.hibernate.type'
debug 'org.hibernate.SQL'
environments {
development {
all 'grails.app'
root {
all 'stdout'
}
}
test {
info 'grails.app'
root {
info 'stdout'
}
}
production {
warn 'grails.app'
root {
warn 'main', 'smtp'
additivity = true
}
}
}
}
source
share