You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@grails.apache.org by "jamesfredley (via GitHub)" <gi...@apache.org> on 2026/05/29 04:06:25 UTC
[PR] Disable Jansi in generated logback-spring.xml to fix console logging after DevTools restart [grails-core]
jamesfredley opened a new pull request, #15694:
URL: https://github.com/apache/grails-core/pull/15694
## Summary
Grails Forge generated `grails-app/conf/logback-spring.xml` with `<withJansi>true</withJansi>` on non-Windows operating systems. This breaks console logging after the first Spring Boot DevTools restart.
## Root cause
- Jansi's `AnsiConsole.systemInstall()` globally replaces `System.out`/`System.err` and tracks installation with a static reference counter. That state lives in the Spring Boot DevTools **base** classloader, so it survives restarts.
- Logback's `ConsoleAppender` calls `systemInstall()` on `start()` but never calls `systemUninstall()` on `stop()`. After the first DevTools restart, the old appender closes the shared Jansi stream while the counter stays above zero, so `systemInstall()` is a no-op and the new appender writes to a closed, stale stream. Console logging then silently stops - exactly the reported behavior (works at startup, dies after the first reload).
- Spring Boot deliberately does **not** enable Jansi in its own logback defaults; it renders ANSI colors via its own `AnsiOutput` and the `%clr` converter, which does not replace `System.out`. There is therefore no benefit to enabling Jansi.
## Change
- Always generate `<withJansi>false</withJansi>` and remove the now-pointless OS-based toggle in `Logback`, making Forge consistent with the base profile skeleton (which already hardcodes `false`).
- Add a `LogbackSpec` regression test asserting the generated config disables Jansi for every application type.
## Verification
- `:grails-forge-core:compileJava` passes and the generated Rocker template emits the literal `<withJansi>false</withJansi>`.
- New `LogbackSpec` test covers all application types.
Fixes #15663
--
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: notifications-unsubscribe@grails.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Disable Jansi in generated logback-spring.xml to fix console logging after DevTools restart [grails-core]
Posted by "testlens-app[bot] (via GitHub)" <gi...@apache.org>.
testlens-app[bot] commented on PR #15694:
URL: https://github.com/apache/grails-core/pull/15694#issuecomment-4686112179
## ✅ All tests passed ✅
🏷️ Commit: 448d435be0bd25008e51d5b22610fd303daca96b
▶️ Tests: 7348 executed
⚪️ Checks: 33/33 completed
---
_Learn more about TestLens at [testlens.app](https://testlens.app)._
--
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: notifications-unsubscribe@grails.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Disable Jansi in generated logback-spring.xml to fix console logging after DevTools restart [grails-core]
Posted by "jdaugherty (via GitHub)" <gi...@apache.org>.
jdaugherty commented on PR #15694:
URL: https://github.com/apache/grails-core/pull/15694#issuecomment-4605312000
> @jdaugherty we should look into why Spring Boot deliberately does **not** enable Jansi in its own logback defaults. This has been a landmine for Grails for multiple versions. Color is nice, but not at the cost that has been paid, and this time this is Mac/Linux too.
>
> The PR that updates Jansi for CLI, might improve this situation. No sure.
Windows is horrible with utf-8 / coloring. It's the only platform that has this issue. For why Spring Boot doesn't use that default, it doesn't have a lot of defaults. That doesn't stop us from having convention over configuration. This should be a requirement of Linux/Mac OS
--
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: notifications-unsubscribe@grails.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Disable Jansi in generated logback-spring.xml to fix console logging after DevTools restart [grails-core]
Posted by "jdaugherty (via GitHub)" <gi...@apache.org>.
jdaugherty commented on PR #15694:
URL: https://github.com/apache/grails-core/pull/15694#issuecomment-4738100395
I confirmed jansi only benefits windows and only added color support for older versions. I am inclinded to remove it since @jamesfredley is the requester. Lets fix the color config in the gradle plugin and then we can merge.
--
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: notifications-unsubscribe@grails.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Disable Jansi in generated logback-spring.xml to fix console logging after DevTools restart [grails-core]
Posted by "jamesfredley (via GitHub)" <gi...@apache.org>.
jamesfredley commented on PR #15694:
URL: https://github.com/apache/grails-core/pull/15694#issuecomment-4603176307
@jdaugherty we should look into why Spring Boot deliberately does **not** enable Jansi in its own logback defaults. This has been a landmine for Grails for multiple versions. Color is nice, but not at the cost that has been paid, and this time this is Mac/Linux too.
The PR that updates Jansi for CLI, might improve this situation. No sure.
--
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: notifications-unsubscribe@grails.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Disable Jansi in generated logback-spring.xml to fix console logging after DevTools restart [grails-core]
Posted by "jdaugherty (via GitHub)" <gi...@apache.org>.
jdaugherty commented on PR #15694:
URL: https://github.com/apache/grails-core/pull/15694#issuecomment-4738091221
fyi: matching is non-lazy gradle. We should only configure the task. Ideally this would be done the gradle plugin and not in end user apps.
--
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: notifications-unsubscribe@grails.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Disable Jansi in generated logback-spring.xml to fix console logging after DevTools restart [grails-core]
Posted by "jdaugherty (via GitHub)" <gi...@apache.org>.
jdaugherty commented on code in PR #15694:
URL: https://github.com/apache/grails-core/pull/15694#discussion_r3498509665
##########
grails-gradle/plugins/src/main/groovy/org/grails/gradle/plugin/core/GrailsGradlePlugin.groovy:
##########
@@ -846,6 +846,7 @@ class GrailsGradlePlugin extends GroovyPlugin {
project.tasks.withType(BootRun).configureEach { BootRun it ->
it.dependsOn(findMainClassTask)
it.mainClass.convention(GrailsGradlePlugin.getMainClassProvider(project))
+ it.systemProperty('spring.output.ansi.console-available', 'true')
Review Comment:
Shouldn't this be where OS != Windows?
##########
grails-forge/grails-forge-core/src/main/java/org/grails/forge/feature/logging/template/logback.rocker.raw:
##########
@@ -17,14 +17,14 @@ specific language governing permissions and limitations
under the License.
*@
-@args (String projectName, String packageName, boolean jansi)
+@args (String projectName, String packageName)
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<include resource="org/springframework/boot/logging/logback/defaults.xml"/>
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
- <withJansi>@jansi</withJansi>
+ <withJansi>false</withJansi>
Review Comment:
Should we add a comment that this is incompatible with some reloading tools?
--
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: notifications-unsubscribe@grails.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Disable Jansi in generated logback-spring.xml to fix console logging after DevTools restart [grails-core]
Posted by "jamesfredley (via GitHub)" <gi...@apache.org>.
jamesfredley commented on PR #15694:
URL: https://github.com/apache/grails-core/pull/15694#issuecomment-4724083095
The `withJansi=false` change is correct and doesn't cost us colors on Mac/Linux - I checked the Spring Boot 4 source to be sure.
Colors come from Spring Boot's `%clr` converter (`AnsiOutput`/`ColorConverter`), which the template already uses via `${CONSOLE_LOG_PATTERN}`. That path is completely independent of Jansi:
- In a real terminal, `%clr` colors render on Mac/Linux whether `withJansi` is true or false - the terminal interprets ANSI natively. Jansi only ever mattered for legacy Windows consoles.
- Under `./gradlew bootRun`, `System.console()` is null, so `AnsiOutput`'s DETECT mode emits no colors *regardless of Jansi*. So the old `withJansi=true` gave us no colors under `bootRun` anyway - it only added the DevTools landmine.
So we lose nothing by dropping Jansi, and we can keep the Mac/Linux colors - by convention, even under `bootRun` - the proper way. Pushed a follow-up commit that adds this to the generated `build.gradle`:
```groovy
tasks.matching { it.name == 'bootRun' }.configureEach {
systemProperty 'spring.output.ansi.console-available', 'true'
}
```
`spring.output.ansi.console-available=true` tells Spring Boot's `AnsiOutput` to make the per-OS decision at runtime: colors on Linux/macOS and modern Windows terminals, and automatically off on legacy Windows consoles (no raw escape codes). It's scoped to `bootRun` so it never leaks ANSI into prod/CI logs, and it has none of Jansi's global `System.out` state - so no DevTools restart breakage on any platform. Net effect: better colors on Mac/Linux than the old Jansi toggle ever delivered, with the Windows landmine gone.
--
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: notifications-unsubscribe@grails.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Disable Jansi in generated logback-spring.xml to fix console logging after DevTools restart [grails-core]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #15694:
URL: https://github.com/apache/grails-core/pull/15694#issuecomment-4602701563
<!-- Bito Reply -->
The change explicitly sets `<withJansi>false</withJansi>` in the `logback-spring.xml` template, removing the previous logic that conditionally enabled Jansi based on the operating system. This modification is intended to prevent issues with console logging after a Spring Boot DevTools restart, as noted in the added test case in `LogbackSpec.groovy`.
**grails-forge/grails-forge-core/src/main/java/org/grails/forge/feature/logging/template/logback.rocker.raw**
```
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
- <withJansi>@jansi</withJansi>
+ <withJansi>false</withJansi>
```
--
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: notifications-unsubscribe@grails.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Disable Jansi in generated logback-spring.xml to fix console logging after DevTools restart [grails-core]
Posted by "jamesfredley (via GitHub)" <gi...@apache.org>.
jamesfredley commented on PR #15694:
URL: https://github.com/apache/grails-core/pull/15694#issuecomment-4794421889
Updated for the latest review feedback:
- Removed the generated `tasks.matching { it.name == 'bootRun' }` block from Forge's `build.gradle` template.
- Moved `spring.output.ansi.console-available=true` into `GrailsGradlePlugin` using the existing lazy `project.tasks.withType(BootRun).configureEach` configuration path.
- Updated `LogbackSpec` to assert generated apps no longer inline the `bootRun` ANSI config.
- Added a Grails Gradle plugin TestKit fixture/spec assertion that `BootRun` receives the Spring Boot console availability system property from the plugin.
Verified with:
- `./gradlew :grails-gradle-plugins:test --tests org.grails.gradle.plugin.core.GrailsGradlePluginToolchainSpec`
- `./gradlew :grails-forge-core:test --tests org.grails.forge.feature.logging.LogbackSpec`
--
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: notifications-unsubscribe@grails.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Disable Jansi in generated logback-spring.xml to fix console logging after DevTools restart [grails-core]
Posted by "testlens-app[bot] (via GitHub)" <gi...@apache.org>.
testlens-app[bot] commented on PR #15694:
URL: https://github.com/apache/grails-core/pull/15694#issuecomment-4605968713
## ✅ All tests passed ✅
🏷️ Commit: ab395d688a994815a7f31ceb6b3b9fcee006c19c
▶️ Tests: 12960 executed
⚪️ Checks: 32/32 completed
---
_Learn more about TestLens at [testlens.app](https://testlens.app)._
--
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: notifications-unsubscribe@grails.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Disable Jansi in generated logback-spring.xml to fix console logging after DevTools restart [grails-core]
Posted by "jdaugherty (via GitHub)" <gi...@apache.org>.
jdaugherty commented on code in PR #15694:
URL: https://github.com/apache/grails-core/pull/15694#discussion_r3341400511
##########
grails-forge/grails-forge-core/src/main/java/org/grails/forge/feature/logging/Logback.java:
##########
@@ -61,17 +60,10 @@ public boolean shouldApply(ApplicationType applicationType, Options options, Set
@Override
public void apply(GeneratorContext generatorContext) {
- OperatingSystem operatingSystem = generatorContext.getOperatingSystem();
- boolean jansi = false;
-
- if (operatingSystem != OperatingSystem.WINDOWS) {
Review Comment:
This breaks color logging on other OSs. I don't agree with this solution.
--
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: notifications-unsubscribe@grails.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Disable Jansi in generated logback-spring.xml to fix console logging after DevTools restart [grails-core]
Posted by "testlens-app[bot] (via GitHub)" <gi...@apache.org>.
testlens-app[bot] commented on PR #15694:
URL: https://github.com/apache/grails-core/pull/15694#issuecomment-4724371370
## ✅ All tests passed ✅
🏷️ Commit: 8e8171925baa581969f266d51108fed5d246c172
▶️ Tests: 23724 executed
⚪️ Checks: 33/33 completed
---
_Learn more about TestLens at [testlens.app](https://testlens.app)._
--
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: notifications-unsubscribe@grails.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Disable Jansi in generated logback-spring.xml to fix console logging after DevTools restart [grails-core]
Posted by "testlens-app[bot] (via GitHub)" <gi...@apache.org>.
testlens-app[bot] commented on PR #15694:
URL: https://github.com/apache/grails-core/pull/15694#issuecomment-4811530091
## ✅ All tests passed ✅
🏷️ Commit: 198eef02a81dc365c175462c674f88533f07721a
▶️ Tests: 23594 executed
⚪️ Checks: 33/33 completed
---
_Learn more about TestLens at [testlens.app](https://testlens.app)._
--
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: notifications-unsubscribe@grails.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Disable Jansi in generated logback-spring.xml to fix console logging after DevTools restart [grails-core]
Posted by "jamesfredley (via GitHub)" <gi...@apache.org>.
jamesfredley commented on code in PR #15694:
URL: https://github.com/apache/grails-core/pull/15694#discussion_r3499818327
##########
grails-forge/grails-forge-core/src/main/java/org/grails/forge/feature/logging/template/logback.rocker.raw:
##########
@@ -17,14 +17,14 @@ specific language governing permissions and limitations
under the License.
*@
-@args (String projectName, String packageName, boolean jansi)
+@args (String projectName, String packageName)
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<include resource="org/springframework/boot/logging/logback/defaults.xml"/>
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
- <withJansi>@jansi</withJansi>
+ <withJansi>false</withJansi>
Review Comment:
Good call - added an explanatory comment above `<withJansi>false</withJansi>` in the generated `logback-spring.xml`. It notes that Jansi is intentionally disabled because it replaces `System.out` globally, which is incompatible with reloading tools (Spring Boot DevTools) and breaks console logging after a restart, and that colors come from Spring Boot's `%clr` converter via `CONSOLE_LOG_PATTERN` so Jansi isn't needed. Done in a392fc918c.
##########
grails-gradle/plugins/src/main/groovy/org/grails/gradle/plugin/core/GrailsGradlePlugin.groovy:
##########
@@ -846,6 +846,7 @@ class GrailsGradlePlugin extends GroovyPlugin {
project.tasks.withType(BootRun).configureEach { BootRun it ->
it.dependsOn(findMainClassTask)
it.mainClass.convention(GrailsGradlePlugin.getMainClassProvider(project))
+ it.systemProperty('spring.output.ansi.console-available', 'true')
Review Comment:
It doesn't need the `OS != Windows` guard - setting `spring.output.ansi.console-available=true` is not a force-on. Spring Boot's `AnsiOutput` in DETECT mode (the default) still gates Windows out internally: `detectIfAnsiCapable()` ends with `return !(OPERATING_SYSTEM_NAME.contains(\win\))` (verified in Spring Boot 3.5.x `AnsiOutput`). So on legacy Windows consoles no raw ANSI escapes are emitted regardless of this property; the only thing it does is tell AnsiOutput a console is available under `bootRun` (where `System.console()` is null), enabling colors on macOS/Linux and modern terminals. Setting it unconditionally is therefore correct, and an OS check here would just duplicate Spring Boot's own logic. I've added a code comment explaining this above the line in a392fc918c.
--
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: notifications-unsubscribe@grails.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Disable Jansi in generated logback-spring.xml to fix console logging after DevTools restart [grails-core]
Posted by "jamesfredley (via GitHub)" <gi...@apache.org>.
jamesfredley merged PR #15694:
URL: https://github.com/apache/grails-core/pull/15694
--
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: notifications-unsubscribe@grails.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org