[
https://issues.apache.org/jira/browse/LOG4J2-1685?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15658306#comment-15658306
]
Raman Gupta commented on LOG4J2-1685:
-------------------------------------
Yes, you're right about the intent -- some environments have a console, but do
not have ANSI support, so `noConsoleNoAnsi` does not apply. In this case, we
want to be able to easily disable the ANSI escapes without having to provide a
completely different pattern. With the approach in my patch, `disableAnsi` can
easily be set via a system property, and defaulted, in log4j2.xml using the
standard string interpolation mechanism. As you say, I guess it could work with
script support but a) I couldn't find any example of how to use the script
support to do this kind of thing, and b) it seems like a really overly
complicated solution for what should be a simple toggle from the user's
perspective. Hence my patch submission.
FYI, I had `disableAnsi` in PatternLayout.Builder, but it Looks like Mikael
removed it from there explicitly to avoid a BC break in this post-patch commit:
https://github.com/apache/logging-log4j2/commit/6630eae39220c31cda185ef4d46538671e04fa64
I certainly agree that this type of change really should not cause such
far-reaching signature changes -- it was quite a hassle preparing this patch.
It really seemed to be bad code smell to have so many methods with such similar
*long* argument lists.
> Single property to disable all color output
> -------------------------------------------
>
> Key: LOG4J2-1685
> URL: https://issues.apache.org/jira/browse/LOG4J2-1685
> Project: Log4j 2
> Issue Type: Improvement
> Components: Appenders
> Affects Versions: 2.7
> Reporter: Raman Gupta
> Assignee: Mikael Ståldal
> Priority: Minor
>
> I am deploying an app to a Windows server. The app will write logs to
> standard output which will then be captured by some wrapper process.
> My default configuration contains ansi escapes for color, because they are
> nice for every situation except this one.
> It would be nice if there was a simple way to disable all ansi output via a
> system property and/or environment variable e.g.
> `-Dlog4j.ansi.enabled=false`
> This would operate similarly to the Spring Boot `spring.output.ansi.enabled`
> property
> (http://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-logging.html).
> In Spring Boot I believe this is handled by using conditionals in their
> logback configuration (which would be super-nice in log4j also). With
> conditional layout I could very easily do this myself by specifying two
> different Pattern layouts in my config file, one with color and one without,
> conditional on some system property or env var I define.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]