Index: /trunk/grails-app/conf/Config.groovy
===================================================================
--- /trunk/grails-app/conf/Config.groovy	(revision 196)
+++ /trunk/grails-app/conf/Config.groovy	(revision 197)
@@ -36,41 +36,95 @@
 grails.enable.native2ascii = true
 
-// set per-environment serverURL stem for creating absolute links
-environments {
-    production {
-        grails.serverURL = "http://www.changeme.com"
+/**
+ * Start of log4j configuration.
+ * Causing this file to reload (e.g. edit/save) may break the appLog destination
+ * and further logs will be written to files or directories like "[:]"
+ * For more info see http://logging.apache.org/log4j/1.2/manual.html
+ * For log levels see http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/Level.html
+ * Basic log levels are ALL < TRACE < DEBUG < INFO < WARN < ERROR < FATAL < OFF
+ */
+def logDirectory = '.'
+
+log4j = {
+    appenders {
+        // Use if we want to prevent creation of a stacktrace.log file.
+        // Beware that since we are using assingment above 'log4j =' this may override things you did not want to.
+        'null' name:'stacktrace'
+
+        // Use this if we want to modify the default appender called 'stdout'.
+        console name:'stdout', layout:pattern(conversionPattern: '[%t] %-5p %c{2} %x - %m%n')
+
+        // Custom log file.
+        rollingFile name:"appLog",
+                        file:"${logDirectory}/${appName}.log".toString(),
+                        maxFileSize:'1MB',
+                        maxBackupIndex:0,
+                        layout:pattern(conversionPattern: '%d{[EEE, dd-MMM-yyyy @ HH:mm:ss.SSS]} [%t] %-5p %c %x - %m%n')
     }
+
+    // Configure the root logger to output to stdout and appLog appenders.
+    root {
+        error 'stdout','appLog'
+        additivity = true
+    }
+
+    // This is for the builtin stuff and from the default Grails-1.1.1 config.
+    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'
+
+    warn   'org.mortbay.log' // Jetty
+
+    error "grails.app" // Set the default log level for our app code.
+    info "grails.app.bootstrap" // Set the log level per type and per type.class
+    debug "grails.app.service"
+    debug "grails.app.controller"
+    error "grails.app.service.PersonService"
+    error "grails.app.service.NavigationService"
 }
 
-// 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.stacktraceLog = "org.apache.log4j.FileAppender"
-    appender.'stacktraceLog.layout'="org.apache.log4j.PatternLayout"
-    appender.'stacktraceLog.layout.ConversionPattern'='[%r] %c{2} %m%n'
-    appender.'stacktraceLog.File'="stacktrace.log"
-    rootLogger="error,stdout"
-    logger {
-        grails="error"
-        StackTrace="error,stacktraceLog"
-        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"
+/**
+ * Environment specific configuration.
+ */
+environments {
+
+    production {
+        grails.serverURL = "http://www.changeme.com" // Set serverURL stem for creating absolute links.
+        log4j {
+            appenders {
+                // Pickup the Tomcat/Catalina logDirectory else use the current dir.
+                def catalinaBase = System.properties.getProperty('catalina.base')
+                logDirectory = catalinaBase ? "${catalinaBase}/logs" : '.'
+
+                rollingFile name:"appLog",
+                                file:"${logDirectory}/${appName}.log".toString(),
+                                maxFileSize:'1MB',
+                                maxBackupIndex:0,
+                                layout:pattern(conversionPattern: '%d{[EEE, dd-MMM-yyyy @ HH:mm:ss.SSS]} [%t] %-5p %c %x - %m%n')
+
+            }
+            error "grails.app" // Set the default log level for our app code.
+            info "grails.app.bootstrap" // Set the log level per type and per type.class
+            warn "grails.app.service"
+            warn "grails.app.controller"
         }
     }
-    additivity.StackTrace=false
-}
 
-//log4j.logger.org.springframework.security='off,stdout'
+    development {
+        grails.serverURL = "http://localhost:8080/${appName}" // Set serverURL stem for creating absolute links.
+    }
+
+    test {
+        grails.serverURL = "http://localhost:8080/${appName}" // Set serverURL stem for creating absolute links.
+    }
+
+} // end environments
 
 /** Navigation plugin menu.
