9

When I start Micronaut project, in the IntelliJ it shows me at the Run box error that

Caused by: java.lang.ClassNotFoundException: org.fusesource.jansi.WindowsAnsiOutputStream

I know that is something which makes console output better, but I didn't found how fix it. Project ran successfully, but I want to try fix it...

Intellij screenshot

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Andrew Sneck
  • 724
  • 9
  • 18

2 Answers2

16

It is a problem with colored logging in Logback on Windows. To workaround that you can set withJansi to false in logback.xml config file:

<configuration>
    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
        <withJansi>false</withJansi>
        <encoder>
            <pattern>%cyan(%d{HH:mm:ss.SSS}) %gray([%thread]) %highlight(%-5level) %magenta(%logger{36}) - %msg%n</pattern>
        </encoder>
    </appender>
    ...
</configuration>

There is also an Issue created for that, see: https://github.com/micronaut-projects/micronaut-core/issues/1521

cgrim
  • 4,890
  • 1
  • 23
  • 42
1

Previous answer removes the error but not fixes the issue. If you read comment on logback.xml you will see there is a library for Java on Windows that will show logs with colors.

I don't know if you are using Maven or SBT but adding next dependency will fix your issue.

Maven:

<dependency>
  <groupId>org.fusesource.jansi</groupId>
  <artifactId>jansi</artifactId>
  <version>2.3.4</version>
</dependency>

Sbt:

libraryDependencies += "org.fusesource.jansi" % "jansi" % "2.3.4"

https://search.maven.org/artifact/org.fusesource.jansi/jansi/2.3.4/jar

Carlos Verdes
  • 3,037
  • 22
  • 20
  • This dependency helped, but I had to use version 1.18 since `org.fusesource.jansi.WindowsAnsiOutputStream` is not present in later versions. – Martin Jul 28 '22 at 20:04