0
我是grails新手,需要爲我的應用程序配置loggind。我開始在我的Grails應用程序配置log4j,我得到了下面描述的這個錯誤,我不知道是什麼讓這樣的:配置log4j grails
log4j:ERROR Property missing when configuring log4j: Environment
有人知道是什麼原因造成的?以下是我的代碼!
def myappLogLevel = "DEBUG"
def myappLogPattern = "%d{yyyy-MM-dd/HH:mm:ss.SSS} [%t] %x %-5p %c{2} -
%m%n"
def log4jFileName = System.properties.getProperty('catalina.base', '.') +
"/logs/myapp.log"
environments {
development {
log4jFileName = "logs/myapp.log"
}
test {
log4jFileName = "logs/myapp.log"
}
log4j = {
def logLayoutPattern = new PatternLayout(myappLogPattern)
appenders {
appender new DailyRollingFileAppender(name: "myappLog",
threshold: Level.toLevel(myappLogLevel),
file: log4jFileName,
datePattern: "'.'yyyy-MM-dd", //Rollover at midnight each day.
layout: logLayoutPattern
)
if (Environment.current == Environment.DEVELOPMENT ||
Environment.current == Environment.TEST) {
appender new ConsoleAppender(name: "console",
threshold: Level.toLevel(myappLogLevel),
layout: logLayoutPattern
)
}
}
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
'org.springframework',
'org.hibernate.cache',
'org.hibernate',
'net.sf.ehcache.hibernate'
'grails'
'groovyx.net.http'
warn 'org.springframework',
'org.hibernate',
'grails.plugins.springsecurity',
'groovyx.net.http'
debug 'grails.plugins.springsecurity',
'grails.plugin.springcache',
'com.myapp',
'org.codehaus.groovy.grails.plugins.springsecurity',
'org.apache.http.headers',
'grails.app.services',
'grails.app.domain',
'grails.app.controllers',
'grails.plugin.databasemigration',
'liquibase'
List<String> loggers = []
loggers.add('myappLog')
if (Environment.current.name == "development" ||
Environment.current.name == "test") {
loggers.add('console')
}
root {
error loggers as String[]
additivity = true
}
}
您需要導入grails.util.Environment以使Environment可用。 – railsdog