In my Logback configuration I have the following lines:
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%highlight(...) %msg%n</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>WARN</level>
</filter>
</appender>
This makes warnings and errors show up in terminal, colored, while main log file can contain much more information, e.g. INFO and DEBUG levels.
Generally, this works fine. But, when I run it from Emacs or any other "not really a terminal" program, coloring commands show out as ASCII escape sequences, e.g. ^[[31m
for warning highlighting. Is it somehow possible to make Logback only use ANSI coloring when connected to a real terminal?
Here an example for logback console appender;