Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Cannot Reproduce
-
Affects Version/s: 1.0-RC4
-
Fix Version/s: 1.1.1
-
Component/s: Configuration
-
Labels:None
Description
When creating an app with grails create-app, the top section of the config.groovy file:
// locations to search for config files that get merged into the main config
// config files can either be Java properties files or ConfigSlurper scripts
// grails.config.locations = [ "classpath:${appName}-config.properties",
// "classpath:${appName}-config.groovy",
// "file:${userHome}/.grails/${appName}-config.properties",
// "file:${userHome}/.grails/${appName}-config.groovy"]
// if(System.properties["${appName}.config.location"]) {
// grails.config.locations << "file:" + System.properties["${appName}.config.location"]
// }
grails.mime.file.extensions = true // enables the parsing of file extensions from URLs into the request format
grails.mime.types = [ html: ['text/html','application/xhtml+xml'],
xml: ['text/xml', 'application/xml'],
text: 'text-plain',
js: 'text/javascript',
rss: 'application/rss+xml',
atom: 'application/atom+xml',
css: 'text/css',
csv: 'text/csv',
all: '/',
json: ['application/json','text/json'],
form: 'application/x-www-form-urlencoded',
multipartForm: 'multipart/form-data'
]
// The default codec used to encode data with ${}
grails.views.default.codec="none" // none, html, base64
// enabled native2ascii conversion of i18n properties files
grails.enable.native2ascii = true
makes environment specific logging fail.
Activity
- All
- Comments
- Work Log
- History
- Activity
- Git Commits
I can confirm this behavior on snapshot, I had to move the logging entries to the top.
Doesn't seem to be reproducable against SVN head for me. I have this Config.groovy
// locations to search for config files that get merged into the main config // config files can either be Java properties files or ConfigSlurper scripts // grails.config.locations = [ "classpath:${appName}-config.properties", // "classpath:${appName}-config.groovy", // "file:${userHome}/.grails/${appName}-config.properties", // "file:${userHome}/.grails/${appName}-config.groovy"] // if(System.properties["${appName}.config.location"]) { // grails.config.locations << "file:" + System.properties["${appName}.config.location"] // } grails.mime.file.extensions = true // enables the parsing of file extensions from URLs into the request format grails.mime.types = [ html: ['text/html','application/xhtml+xml'], xml: ['text/xml', 'application/xml'], text: 'text-plain', js: 'text/javascript', rss: 'application/rss+xml', atom: 'application/atom+xml', css: 'text/css', csv: 'text/csv', all: '*/*', json: ['application/json','text/json'], form: 'application/x-www-form-urlencoded', multipartForm: 'multipart/form-data' ] // The default codec used to encode data with ${} grails.views.default.codec="none" // none, html, base64 grails.views.gsp.encoding="UTF-8" // enabled native2ascii conversion of i18n properties files grails.enable.native2ascii = true // log4j configuration log4j { appender.stdout = "org.apache.log4j.ConsoleAppender" appender.'stdout.layout'="org.apache.log4j.PatternLayout" appender.'stdout.layout.ConversionPattern'='[%r] %c{2} %m%n' appender.errors = "org.apache.log4j.FileAppender" appender.'errors.layout'="org.apache.log4j.PatternLayout" appender.'errors.layout.ConversionPattern'='[%r] %c{2} %m%n' appender.'errors.File'="stacktrace.log" rootLogger="error,stdout" logger { grails="error" StackTrace="error,errors" org { codehaus.groovy.grails.web.servlet="error" // controllers codehaus.groovy.grails.web.pages="error" // GSP codehaus.groovy.grails.web.sitemesh="error" // layouts codehaus.groovy.grails."web.mapping.filter"="error" // URL mapping codehaus.groovy.grails."web.mapping"="error" // URL mapping codehaus.groovy.grails.commons="info" // core / classloading codehaus.groovy.grails.plugins="error" // plugins codehaus.groovy.grails.orm.hibernate="error" // hibernate integration springframework="off" hibernate="off" } } additivity.StackTrace=false } environments { development { log4j { appender.logfile= "org.apache.log4j.DailyRollingFileAppender" appender.'logfile.File' = "WebTestApp.log" appender.'logfile.layout' = "org.apache.log4j.PatternLayout" appender.'logfile.layout.ConversionPattern' = '%d{[ dd.MM.yy HH:mm:ss.SSS]} [%t] %-5p %c %x - %m%n' logger.grails.'app.controller.FooController'="debug,stdout,logfile" } } }
and it results in this log4j:
#Grails' Log4j Configuration
#Wed Jan 30 13:04:45 GMT 2008
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.logger.org.codehaus.groovy.grails.web.mapping=error
log4j.logger.org.springframework=off
log4j.logger.org.codehaus.groovy.grails.web.pages=error
log4j.appender.logfile.layout.ConversionPattern=%d{[ dd.MM.yy HH\:mm\:ss.SSS]} [%t] %-5p %c %x - %m%n
log4j.appender.stdout.layout.ConversionPattern=[%r] %c{2} %m%n
log4j.logger.grails.app.controller.FooController=debug,stdout,logfile
log4j.logger.StackTrace=error,errors
log4j.appender.logfile.File=WebTestApp.log
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.additivity.StackTrace=false
log4j.appender.errors.layout.ConversionPattern=[%r] %c{2} %m%n
log4j.logger.org.codehaus.groovy.grails.web.servlet=error
log4j.appender.errors=org.apache.log4j.FileAppender
log4j.logger.org.codehaus.groovy.grails.orm.hibernate=error
log4j.logger.org.codehaus.groovy.grails.commons=info
log4j.logger.org.codehaus.groovy.grails.plugins=error
log4j.logger.org.hibernate=off
log4j.appender.errors.File=stacktrace.log
log4j.logger.org.codehaus.groovy.grails.web.sitemesh=error
log4j.logger.org.codehaus.groovy.grails.web.mapping.filter=error
log4j.rootLogger=error,stdout
log4j.appender.logfile.layout=org.apache.log4j.PatternLayout
log4j.appender.errors.layout=org.apache.log4j.PatternLayout
log4j.appender.logfile=org.apache.log4j.DailyRollingFileAppender
// locations to search for config files that get merged into the main config // config files can either be Java properties files or ConfigSlurper scripts // grails.config.locations = [ "classpath:${appName}-config.properties", // "classpath:${appName}-config.groovy", // "file:${userHome}/.grails/${appName}-config.properties", // "file:${userHome}/.grails/${appName}-config.groovy"] // if(System.properties["${appName}.config.location"]) { // grails.config.locations << "file:" + System.properties["${appName}.config.location"] // } grails.mime.file.extensions = true // enables the parsing of file extensions from URLs into the request format grails.mime.types = [ html: ['text/html','application/xhtml+xml'], xml: ['text/xml', 'application/xml'], text: 'text-plain', js: 'text/javascript', rss: 'application/rss+xml', atom: 'application/atom+xml', css: 'text/css', csv: 'text/csv', all: '*/*', json: ['application/json','text/json'], form: 'application/x-www-form-urlencoded', multipartForm: 'multipart/form-data' ] // The default codec used to encode data with ${} grails.views.default.codec="none" // none, html, base64 grails.views.gsp.encoding="UTF-8" // enabled native2ascii conversion of i18n properties files grails.enable.native2ascii = true // log4j configuration log4j { appender.stdout = "org.apache.log4j.ConsoleAppender" appender.'stdout.layout'="org.apache.log4j.PatternLayout" appender.'stdout.layout.ConversionPattern'='[%r] %c{2} %m%n' appender.errors = "org.apache.log4j.FileAppender" appender.'errors.layout'="org.apache.log4j.PatternLayout" appender.'errors.layout.ConversionPattern'='[%r] %c{2} %m%n' appender.'errors.File'="stacktrace.log" rootLogger="error,stdout" logger { grails="error" StackTrace="error,errors" org { codehaus.groovy.grails.web.servlet="error" // controllers codehaus.groovy.grails.web.pages="error" // GSP codehaus.groovy.grails.web.sitemesh="error" // layouts codehaus.groovy.grails."web.mapping.filter"="error" // URL mapping codehaus.groovy.grails."web.mapping"="error" // URL mapping codehaus.groovy.grails.commons="info" // core / classloading codehaus.groovy.grails.plugins="error" // plugins codehaus.groovy.grails.orm.hibernate="error" // hibernate integration springframework="off" hibernate="off" } } additivity.StackTrace=false } environments { development { log4j { appender.logfile= "org.apache.log4j.DailyRollingFileAppender" appender.'logfile.File' = "WebTestApp.log" appender.'logfile.layout' = "org.apache.log4j.PatternLayout" appender.'logfile.layout.ConversionPattern' = '%d{[ dd.MM.yy HH:mm:ss.SSS]} [%t] %-5p %c %x - %m%n' logger.grails.'app.controller.FooController'="debug,stdout,logfile" } } }
#Grails' Log4j Configuration
#Wed Jan 30 13:04:45 GMT 2008
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.logger.org.codehaus.groovy.grails.web.mapping=error
log4j.logger.org.springframework=off
log4j.logger.org.codehaus.groovy.grails.web.pages=error
log4j.appender.logfile.layout.ConversionPattern=%d{[ dd.MM.yy HH\:mm\:ss.SSS]} [%t] %-5p %c %x - %m%n
log4j.appender.stdout.layout.ConversionPattern=[%r] %c{2} %m%n
log4j.logger.grails.app.controller.FooController=debug,stdout,logfile
log4j.logger.StackTrace=error,errors
log4j.appender.logfile.File=WebTestApp.log
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.additivity.StackTrace=false
log4j.appender.errors.layout.ConversionPattern=[%r] %c{2} %m%n
log4j.logger.org.codehaus.groovy.grails.web.servlet=error
log4j.appender.errors=org.apache.log4j.FileAppender
log4j.logger.org.codehaus.groovy.grails.orm.hibernate=error
log4j.logger.org.codehaus.groovy.grails.commons=info
log4j.logger.org.codehaus.groovy.grails.plugins=error
log4j.logger.org.hibernate=off
log4j.appender.errors.File=stacktrace.log
log4j.logger.org.codehaus.groovy.grails.web.sitemesh=error
log4j.logger.org.codehaus.groovy.grails.web.mapping.filter=error
log4j.rootLogger=error,stdout
log4j.appender.logfile.layout=org.apache.log4j.PatternLayout
log4j.appender.errors.layout=org.apache.log4j.PatternLayout
log4j.appender.logfile=org.apache.log4j.DailyRollingFileAppender
Here's my configuration file. I can't test against rev 6609 since it doesn't run (running 'grails' dumps me back at the command prompt) but as of yesterday it didn't log anything when running 'grails test-app' unless it was organized like this. Sorry I can't provide a revision version.
import grails.util.GrailsUtil
// log4j configuration
log4j {
appender.stdout = "org.apache.log4j.ConsoleAppender"
appender.'stdout.layout'="org.apache.log4j.PatternLayout"
appender.'stdout.layout.ConversionPattern'='[%r] %c{2} %m%n'
appender.logfile = "org.apache.log4j.DailyRollingFileAppender "
appender.'logfile.File' = "projectName.log"
appender.'logfile.layout' = "org.apache.log4j.PatternLayout"
appender.'logfile.layout.ConversionPattern' = '%d{[yy.MM.dd HH:mm:ss.SSS]} [%t] %-5p %c %x - %m%n'
rootLogger="error,stdout"
logger {
grails="error,stdout"
org {
codehaus.groovy.grails.web.servlet="error,stdout" // controllers
codehaus.groovy.grails.web.errors="error,stdout" // web layer errors
codehaus.groovy.grails.web.pages="error,stdout" // GSP
codehaus.groovy.grails.web.sitemesh="error,stdout" // layouts
codehaus.groovy.grails."web.mapping.filter"="error,stdout" // URL mapping
codehaus.groovy.grails."web.mapping"="error,stdout" // URL mapping
codehaus.groovy.grails.commons="info,stdout" // core / classloading
codehaus.groovy.grails.plugins="error,stdout" // plugins
codehaus.groovy.grails.orm.hibernate="error,stdout" // hibernate integration
springframework="off,stdout"
hibernate="off,stdout"
}
}
additivity.'default' = false
additivity {
grails=false
org {
codehaus.groovy.grails=false
springframework=false
hibernate=false
}
}
}
environments {
development {
log4j {
rootLogger="error,stdout"
logger {
grails.'app.controller'="debug,stdout"
grails.'app.service'="debug,stdout"
grails.'app.domain.Account'="error,logfile"
}
}
}
test {
log4j {
//rootLogger="error,logfile"
logger {
grails.'app.controller'="error,logfile"
grails.'app.service'="error,logfile"
grails.'app.domain.Customer'="error,logfile"
grails.'app.domain.Account'="trace,logfile"
}
}
}
}
// locations to search for config files that get merged into the main config
// config files can either be Java properties files or ConfigSlurper scripts
grails.config.locations = [ "classpath:projectName.${GrailsUtil.environment}.properties" /*,
"file:${userHome}/.grails/projectName.${GrailsUtil.environment}.properties" */
]
if(System.properties["${appName}.config.location"]) {
grails.config.locations << "file:" + System.properties["${appName}.config.location"]
}
grails.mime.file.extensions = true // enables the parsing of file extensions from URLs into the request format
grails.mime.types = [ html: ['text/html','application/xhtml+xml'],
//xml: ['text/xml', 'application/xml'],
text: 'text-plain',
js: 'text/javascript',
rss: 'application/rss+xml',
atom: 'application/atom+xml',
css: 'text/css',
csv: 'text/csv',
all: '/',
json: ['application/json','text/json'],
form: 'application/x-www-form-urlencoded',
multipartForm: 'multipart/form-data'
]
// The default codec used to encode data with ${}
grails.views.default.codec="none" // none, html, base64
// enabled native2ascii conversion of i18n properties files
grails.enable.native2ascii = true
Please disregard my command regarding 6609 not working - I've rebuilt it it runs. I still don't get any traces on test unless the configuration is as I pasted it.
This issue is easily repeatable in grails 1.0.1 and groovy 1.5.4.
Please note that the resulting log4j.properties file has no effect. Logging is still broken.
I just created a new app and repeated the steps. Logging does not work unless the top section of the Config.groovy file above the log4j configuration section is placed below the log4j configuration section.
Here's the original Config.groovy file with the offending section at the top of the file:
// locations to search for config files that get merged into the main config
// config files can either be Java properties files or ConfigSlurper scripts
// grails.config.locations = [ "classpath:${appName}-config.properties",
// "classpath:${appName}-config.groovy",
// "file:${userHome}/.grails/${appName}-config.properties",
// "file:${userHome}/.grails/${appName}-config.groovy"]
// if(System.properties["${appName}.config.location"]) {
// grails.config.locations << "file:" + System.properties["${appName}.config.location"]
// }
grails.mime.file.extensions = true // enables the parsing of file extensions from URLs into the request format
grails.mime.types = [ html: ['text/html','application/xhtml+xml'],
xml: ['text/xml', 'application/xml'],
text: 'text-plain',
js: 'text/javascript',
rss: 'application/rss+xml',
atom: 'application/atom+xml',
css: 'text/css',
csv: 'text/csv',
all: '/',
json: ['application/json','text/json'],
form: 'application/x-www-form-urlencoded',
multipartForm: 'multipart/form-data'
]
// The default codec used to encode data with ${}
grails.views.default.codec="none" // none, html, base64
grails.views.gsp.encoding="UTF-8"
grails.converters.encoding="UTF-8"
// enabled native2ascii conversion of i18n properties files
grails.enable.native2ascii = true
// set per-environment serverURL stem for creating absolute links
environments {
production {
grails.serverURL = "http://www.yourexcitingapplication.com"
}
}
// log4j configuration
log4j {
appender.stdout = "org.apache.log4j.ConsoleAppender"
appender.'stdout.layout'="org.apache.log4j.PatternLayout"
appender.'stdout.layout.ConversionPattern'='[%r] %c{2} %m%n'
appender.errors = "org.apache.log4j.FileAppender"
appender.'errors.layout'="org.apache.log4j.PatternLayout"
appender.'errors.layout.ConversionPattern'='[%r] %c{2} %m%n'
appender.'errors.File'="stacktrace.log"
rootLogger="error,stdout"
logger {
grails="error"
StackTrace="error,errors"
org {
codehaus.groovy.grails.web.servlet="error" // controllers
codehaus.groovy.grails.web.pages="error" // GSP
codehaus.groovy.grails.web.sitemesh="error" // layouts
codehaus.groovy.grails."web.mapping.filter"="error" // URL mapping
codehaus.groovy.grails."web.mapping"="error" // URL mapping
codehaus.groovy.grails.commons="info" // core / classloading
codehaus.groovy.grails.plugins="error" // plugins
codehaus.groovy.grails.orm.hibernate="error" // hibernate integration
springframework="off"
hibernate="off"
}
}
environments {
development {
log4j {
appender.logfile= "org.apache.log4j.DailyRollingFileAppender"
appender.'logfile.File' = "coach.log"
appender.'logfile.layout' = "org.apache.log4j.PatternLayout"
appender.'logfile.layout.ConversionPattern' = '%d{[ dd.MM.yy HH:mm:ss.SSS]} [%t] %-5p %c %x - %m%n'
logger {
grails.'app.controller.RegisterController'="trace,stdout,logfile"
grails.'app.domain.Register'="trace,stdout,logfile"
grails.'app.controller.BioMetricsController'="debug,stdout,logfile"
grails.'app.domain.BioMetrics'="debug,stdout,logfile"
grails.'app.controller.ExerciseController'="debug,stdout,logfile"
grails.'app.domain.Exercise'="debug,stdout,logfile"
grails.'app.controller.FoodController'="debug,stdout,logfile"
grails.'app.domain.Food'="debug,stdout,logfile"
grails.'app.controller.MealController'="debug,stdout,logfile"
grails.'app.domain.Meal'="debug,stdout,logfile"
grails.'app.controller.UserController'="trace,stdout,logfile"
grails.'app.domain.User'="trace,stdout,logfile"
grails.'app.controller.WorkoutController'="debug,stdout,logfile"
grails.'app.domain.Workout'="debug,stdout,logfile"
}
}
}
}
additivity.StackTrace=false
}
log4j.logger.org.acegisecurity="off,stdout"
Here is my Config.groovy file that works:
The problem exists in ConfigSlurper, which is part of Groovy so it will have to wait until the next Groovy release. In the meantime the workaround is to instead of this:
logger {
grails.'app.controller.TestController'="debug,stdout,logfile"
grails.'app.domain.User'="debug,stdout,logfile"
}
Use this:
logger.grails.'app.controller.TestController'="debug,stdout,logfile" logger.grails.'app.domain.User'="debug,stdout,logfile"
Which scopes the settings appropriately
logger {
grails.'app.controller.TestController'="debug,stdout,logfile"
grails.'app.domain.User'="debug,stdout,logfile"
}
logger.grails.'app.controller.TestController'="debug,stdout,logfile" logger.grails.'app.domain.User'="debug,stdout,logfile"
to reproduce:
1. Create a new grails app with
grails create-app
2. create a new controller and domain.
3. add an environments section to the config.groovy file and specify the new domain controller and domain:
environments {
development {
log4j {
appender.logfile= "org.apache.log4j.DailyRollingFileAppender"
appender.'logfile.File' = "WebTestApp.log"
appender.'logfile.layout' = "org.apache.log4j.PatternLayout"
appender.'logfile.layout.ConversionPattern' = '%d{[ dd.MM.yy HH:mm:ss.SSS]} [%t] %-5p %c %x - %m%n'
logger { grails.'app.controller.UserController'="debug,stdout,logfile" grails.'app.domain.User'="debug,stdout,logfile" }
}
}
}
4. add logging to the controller CRUD methods like log.debug("Some debug info");
5. Run the app. You will see no logging.
6. Comment out the top section above the log4j configuration part of the config.groovy file.
7. Run the app. You will see the log.debug output.
Hope this helps.