简体   繁体   中英

Getting weird characters in logs while running Spring application on terminal

I'm running a Java Spring application on my local machine and I'm getting two different kinds of logs depending upon where I run it. I've tried using different Terminal apps. Also tried different shells (zsh and bash), but the issue still remains. Running it via the IntelliJ Run tab produces normal logs like this (I'm using Java 16):


  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::       (v2.3.12.RELEASE)

2023-01-10 18:08:15.863  INFO 82231 --- [           main] c.v.c.s.SaasControllerApplication        : Starting SaasControllerApplication on patelhiXMD6M.vmware.com with PID 82231 (/Users/user/workspace/saas-infra/saas-controller/target/classes started by user in /Users/user/workspace/saas-infra)
2023-01-10 18:08:15.876  INFO 82231 --- [           main] c.v.c.s.SaasControllerApplication        : No active profile set, falling back to default profiles: default
2023-01-10 18:08:16.536  INFO 82231 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2023-01-10 18:08:16.659  INFO 82231 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 119ms. Found 8 JPA repository interfaces.

However when I run the code in terminal I'm receiving logs like this:


  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::       (v0.001-SNAPSHOT)

%.S.S.S.S.RepositoryConfigurationDelegatelr %.%.%.%.%.RepositoryConfigurationDelegatelr %.%.%.%.%.RepositoryConfigurationDelegatelr -.-.-.-.-.RepositoryConfigurationDelegatelr [.s5.d5.r5.c5.RepositoryConfigurationDelegatelr %.spri0.}.}.}.RepositoryConfigurationDelegatelr :.:.:.:.:.RepositoryConfigurationDelegatelr Bootstrapping Spring Data JPA repositories in DEFAULT mode.
[]wEx%.S.S.S.S.RepositoryConfigurationDelegatelr %.%.%.%.%.RepositoryConfigurationDelegatelr %.%.%.%.%.RepositoryConfigurationDelegatelr -.-.-.-.-.RepositoryConfigurationDelegatelr [.s5.d5.r5.c5.RepositoryConfigurationDelegatelr %.spri0.}.}.}.RepositoryConfigurationDelegatelr :.:.:.:.:.RepositoryConfigurationDelegatelr Finished Spring Data repository scanning in 145ms. Found 8 JPA repository interfaces.
[]wEx%.S.S.S.StandardServicelr %.%.%.%.StandardServicelr %.%.%.%.StandardServicelr -.-.-.-.StandardServicelr [.a5.c5.c5.StandardServicelr %.apac0.}.}.StandardServicelr :.:.:.:.StandardServicelr Starting service [Tomcat]
[]wEx%.S.S.S.StandardEnginelr %.%.%.%.StandardEnginelr %.%.%.%.StandardEnginelr -.-.-.-.StandardEnginelr [.a5.c5.c5.StandardEnginelr %.apac0.}.}.StandardEnginelr :.:.:.:.StandardEnginelr Starting Servlet engine: [Apache Tomcat/9.0.46]
[]wEx%.S.S.S.S.S.S.[/]lr %.%.%.%.%.%.%.[/]lr %.%.%.%.%.%.%.[/]lr -.-.-.-.-.-.-.[/]lr [.a5.c5.c5.C5.[5.[5.[/]lr %.apac0.}.}.}.}.}.[/]lr :.:.:.:.:.:.:.[/]lr Initializing Spring embedded WebApplicationContext
[]wEx%.S.S.HikariDataSourcelr %.%.%.HikariDataSourcelr %.%.%.HikariDataSourcelr -.-.-.HikariDataSourcelr [.z5.h5.HikariDataSourcelr %.zaxx0.}.HikariDataSourcelr :.:.:.HikariDataSourcelr HikariPool-1 - Starting...

I'm using the same pom and properties file for both the runs so I don't understand what's making the difference between the two.

Try to run the jar file with file.encoding option:

java -Dfile.encoding=UTF-8 -jar target/app-0.001-SNAPSHOT.jar

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM