codeconsole commented on code in PR #15757:
URL: https://github.com/apache/grails-core/pull/15757#discussion_r3562672879


##########
grails-doc/src/en/guide/conf/config/logging.adoc:
##########
@@ -17,9 +17,37 @@ specific language governing permissions and limitations
 under the License.
 ////
 
-Logging is handled by the https://logback.qos.ch[Logback logging framework] 
and can be configured with the `grails-app/conf/logback-spring.xml` file. See 
the https://docs.spring.io/spring-boot/how-to/logging.html[Spring Boot Logging] 
and 
https://docs.spring.io/spring-boot/reference/features/logging.html#features.logging.logback-extensions[Logging
 Extensions] for all the available options.
-
-The Grails Environments `development`, `test` and `production` can be used 
with <springProfile name="development"> to configure environment specific 
logging.  This was one of the features lost when logback removed groovy 
configuration.  
+Logging is handled by the https://logback.qos.ch[Logback logging framework] 
and can be configured with the `grails-app/conf/logback-spring.xml` file that 
newly generated applications include. The file is optional: an application 
depends on `grails-logging`, which brings in Spring Boot's logging starter, so 
if the file is removed, Logback and Spring Boot's default Logback configuration 
(an `INFO` root logger and a colorized console pattern) are applied 
automatically with *zero configuration*. See the 
https://docs.spring.io/spring-boot/how-to/logging.html[Spring Boot Logging] and 
https://docs.spring.io/spring-boot/reference/features/logging.html#features.logging.logback-extensions[Logging
 Extensions] documentation for all the available options.
+
+For most needs, levels and patterns can be adjusted entirely from 
`application.yml` without any XML:
+
+[source,yaml]
+.application.yml
+----
+logging:
+    level:
+        root: INFO
+        com.example.myapp: DEBUG          # your packages
+        org.hibernate.SQL: DEBUG          # see the generated SQL
+    file:
+        name: logs/myapp.log              # setting this activates Spring 
Boot's file appender

Review Comment:
   Agreed — with the generated file present (the default), `logging.file.name` 
sets `LOG_FILE` but nothing consumes it. Scoped in 2b1902fbc2 using your 
suggested wording: the comment now reads "activates Boot's file appender only 
when no logback-spring.xml is present (otherwise uncomment the file-appender 
include in that file)". Left the upgrade-guide occurrence as-is since it sits 
under "With no configuration file present…".



##########
grails-doc/src/en/guide/conf/config/logging.adoc:
##########
@@ -17,9 +17,37 @@ specific language governing permissions and limitations
 under the License.
 ////
 
-Logging is handled by the https://logback.qos.ch[Logback logging framework] 
and can be configured with the `grails-app/conf/logback-spring.xml` file. See 
the https://docs.spring.io/spring-boot/how-to/logging.html[Spring Boot Logging] 
and 
https://docs.spring.io/spring-boot/reference/features/logging.html#features.logging.logback-extensions[Logging
 Extensions] for all the available options.
-
-The Grails Environments `development`, `test` and `production` can be used 
with <springProfile name="development"> to configure environment specific 
logging.  This was one of the features lost when logback removed groovy 
configuration.  
+Logging is handled by the https://logback.qos.ch[Logback logging framework] 
and can be configured with the `grails-app/conf/logback-spring.xml` file that 
newly generated applications include. The file is optional: an application 
depends on `grails-logging`, which brings in Spring Boot's logging starter, so 
if the file is removed, Logback and Spring Boot's default Logback configuration 
(an `INFO` root logger and a colorized console pattern) are applied 
automatically with *zero configuration*. See the 
https://docs.spring.io/spring-boot/how-to/logging.html[Spring Boot Logging] and 
https://docs.spring.io/spring-boot/reference/features/logging.html#features.logging.logback-extensions[Logging
 Extensions] documentation for all the available options.
+
+For most needs, levels and patterns can be adjusted entirely from 
`application.yml` without any XML:
+
+[source,yaml]
+.application.yml
+----
+logging:
+    level:
+        root: INFO
+        com.example.myapp: DEBUG          # your packages
+        org.hibernate.SQL: DEBUG          # see the generated SQL
+    file:
+        name: logs/myapp.log              # setting this activates Spring 
Boot's file appender
+----
+
+Per-environment levels need no XML either. Grails environments map to Spring 
profiles, so an `environments` block in `application.yml` applies levels to a 
single environment — for example, verbose logging for your own packages in 
development only (a profile-specific `application-development.yml` works as 
well):
+
+[source,yaml]
+.application.yml
+----
+environments:
+    development:
+        logging:
+            level:
+                com.example.myapp: DEBUG
+----
+
+When properties are not enough — custom appenders, structured output, or 
per-environment appender routing — add a `grails-app/conf/logback-spring.xml` 
file. Use the `-spring` variant (not plain `logback.xml`), because it is 
processed by Spring Boot and unlocks `<springProfile>` and `<springProperty>`. 
The Grails environments `development`, `test` and `production` map to the 
corresponding Spring profiles, so `<springProfile name="development">` blocks 
configure environment-specific logging — one of the features lost when Logback 
removed Groovy configuration.
+
+TIP: When generating a project with https://start.grails.org[Grails Forge], 
select the *Zero-config Logback Logging* feature to omit the generated 
`grails-app/conf/logback-spring.xml` and rely entirely on Spring Boot's 
defaults plus `application.yml` tuning as described above.

Review Comment:
   Added in 2b1902fbc2 — a paragraph after the Forge TIP now draws the boundary 
explicitly: without the file you give up what only XML can express 
(`<springProfile>`-conditional appenders/routing — per-environment *levels* 
still work via the `environments` block — and the starter's development-profile 
`StackTrace` logger), while `logging.file.name` auto-activation of the file 
appender only works *without* the file, which is also why the yaml comment 
above is now scoped.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to