-1

I want to log a specific package just to file, instead of to console too.

This specific package generate a lot of log entries, because of this I don't want to pollute console with that messages. I need that log to trace an "random strange bug".

How can I do this?

Beto Neto
  • 3,962
  • 7
  • 47
  • 81

1 Answers1

0

Please check Spring Boot logging documentation. All modern logging frameworks supported by Spring Boot such as Logback or Log4j are super-easy to configure for such cases...

For example using Logback you would do something like that :

<configuration>
    <appender name="FILE" class="ch.qos.logback.core.rolling.FilAppender">
        <file>/var/log/my-app.log</file>
        <encoder>
            <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{35} - %msg%n</pattern>
        </encoder>
    </appender>

    <root level="INFO">
        <appender-ref ref="FILE" />
    </root>
</configuration>

You can also check this other answer to suppress all logback output to console, mine is just an example.

Community
  • 1
  • 1
Pom12
  • 7,622
  • 5
  • 50
  • 69