If you are using spring-boot
, then by default it is using logback
as it's logging mechanism. My suggestion is for you to do changes via logback.xml
file in-order to change the log pattern.
It is a easy fix and create logback.xml
file in your project's resources directory. I will mention below a sample xml
for that. You can use my example and it will solve your issue.
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<!-- Appender for logging within the console -->
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<!-- Pattern of the console logging -->
<!-- %d - Date and time -->
<!-- %thread - Thread name -->
<!-- %level - Log level (%p also works) -->
<!-- %logger - Logger name -->
<!-- %msg - Log message (%m also works) -->
<!-- %n - Line separator -->
<!-- %d{yyyy-MMM-dd HH:mm:ss} - Custom Date/Time format -->
<!-- %-5level - Left justification flag - Use spaces for right padding if characters < 5 -->
<!-- %logger{36} - Abbreviate -->
<!-- [Date and time] [Thread] LoggingLevel : LoggerName - Logging message -->
<pattern>[%thread] %-5level: %logger - %msg%n</pattern>
</encoder>
</appender>
<!-- Logging levels are, in order of precedence -> TRACE, DEBUG, INFO, WARN and ERROR -->
<root level="info">
<appender-ref ref="STDOUT"/>
</root>
</configuration>
Above logback.xml
contains more comments for better understanding. You can control the pattern of your logs as you wish via modifying the <pattern>
.
Hope this solves the issue.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.