codeconsole commented on code in PR #15757:
URL: https://github.com/apache/grails-core/pull/15757#discussion_r3562672196
##########
grails-doc/src/en/guide/upgrading/upgrading80x.adoc:
##########
@@ -1514,3 +1514,60 @@ Both hooks may be used on the same plugin during
migration; when a registrar and
**Bean-definition overriding edge case.** Grails defaults
`spring.main.allow-bean-definition-overriding` to `true`, and under that
default nothing changes: an application bean (from the application class,
`resources.groovy` or `resources.xml`) that uses the same name as a plugin bean
still replaces the plugin's bean. However, because plugin beans now register
earlier and application beans register in a separate, later step, an
application that explicitly sets `spring.main.allow-bean-definition-overriding`
to `false` will see a `BeanDefinitionOverrideException` for an application bean
that shadows a plugin bean — in previous releases the two definitions were
merged before a single registry write, so the shadowing was silent even with
overriding disabled.
**Most applications and plugins need no action.** Behavior only changes where
a plugin bean and a conditional Boot bean competed for the same name or type —
the plugin bean now wins, which is almost always the intended outcome.
+
+==== 34. Zero-Config Logback Logging Is Now Supported
+
+Newly generated Grails 8 applications continue to include a starter
`grails-app/conf/logback-spring.xml` file, but the file is now optional, and
its content has been simplified to match Spring Boot's defaults.
+
+The starter file no longer duplicates Spring Boot's configuration: it composes
Spring Boot's own `defaults.xml` and `console-appender.xml` and sets an `INFO`
root level, while keeping a `<springProfile name="development">` block for
environment-specific logging. Previous Grails releases generated a standalone
configuration with an `ERROR` root level, which suppressed the `WARN` and
`INFO` output — including framework startup warnings — that Spring Boot shows
by default. Existing applications keep whatever configuration they already have.
+
+An application depends on `grails-logging`, which brings in Spring Boot's
logging starter, so if `grails-app/conf/logback-spring.xml` is removed, Logback
and Spring Boot's own default Logback configuration apply automatically. This
matches the Spring Boot convention of needing no logging configuration file
unless one is actually required.
+
+NOTE: A future major release may stop generating
`grails-app/conf/logback-spring.xml` by default in favor of the zero-config
behavior described here. Existing applications that contain the file are
unaffected either way and continue to use it.
+
+With no configuration file present you get Spring Boot's defaults: an `INFO`
root level and a colorized console pattern. Levels and patterns can be tuned
from `application.yml` with no XML:
+
+[source,yaml]
+.application.yml
+----
+logging:
+ level:
+ root: INFO
+ com.example.myapp: DEBUG # your packages
+ org.hibernate.SQL: DEBUG # see the generated SQL
+ pattern:
+ console: "%d{HH:mm:ss.SSS} %-5level %logger{36} - %msg%n"
+ file:
+ name: logs/myapp.log # setting this activates Spring
Boot's file appender
+----
+
+Per-environment logging also needs no XML. 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:
+
+[source,yaml]
+.application.yml
+----
+environments:
+ development:
+ logging:
+ level:
+ com.example.myapp: DEBUG
+----
+
+A profile-specific `grails-app/conf/application-development.yml` containing
the same `logging.level` entries works as well.
+
+Keep (or re-add) a `logback-spring.xml` file when properties are not enough —
for example custom appenders, structured/JSON output, or per-environment
appender routing. Use the `-spring` variant (not plain `logback.xml`), because
it is processed by Spring Boot and unlocks `<springProfile>` and
`<springProperty>`:
+
+[source,xml]
+.grails-app/conf/logback-spring.xml
+----
+<?xml version="1.0" encoding="UTF-8"?>
+<configuration>
+ <include resource="org/springframework/boot/logging/logback/defaults.xml"/>
Review Comment:
Good catch — you're right, with no appender the example silenced everything
it claimed to enable. Fixed in 2b1902fbc2: the example now matches the
generated starter's shape (`defaults.xml` + `console-appender.xml` includes and
a `<root level="INFO">` with the `CONSOLE` appender-ref), and the surrounding
text now states explicitly that a custom `logback-spring.xml` replaces Spring
Boot's bundled configuration entirely and must declare its own appenders.
--
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]