解决终端汉字乱码问题

This commit is contained in:
2026-05-20 15:37:39 +08:00
parent 1b45d6124d
commit c09ca584c3
3 changed files with 15 additions and 2 deletions

2
.vscode/launch.json vendored
View File

@@ -8,7 +8,7 @@
"mainClass": "org.jeecg.JeecgSystemApplication",
"projectName": "jeecg-system-start",
"cwd": "${workspaceFolder}/jeecg-boot/jeecg-module-system/jeecg-system-start",
"vmArgs": "-Dfile.encoding=UTF-8 -Dsun.stdout.encoding=UTF-8 -Dsun.stderr.encoding=UTF-8"
"vmArgs": "-Dfile.encoding=UTF-8 -Dspring.main.banner-mode=log -Dspring.banner.charset=UTF-8 -Dlogging.charset.console=GBK"
}
]
}

View File

@@ -27,5 +27,12 @@
"jeecg-boot-platform"
],
"java.debug.settings.console": "integratedTerminal",
"java.debug.settings.vmArgs": "-Dspring.main.banner-mode=log -Dspring.banner.charset=UTF-8 -Dlogging.charset.console=GBK"
"java.debug.settings.vmArgs": "-Dfile.encoding=UTF-8 -Dspring.main.banner-mode=log -Dspring.banner.charset=UTF-8 -Dlogging.charset.console=GBK",
"terminal.integrated.defaultProfile.windows": "PowerShell",
"terminal.integrated.profiles.windows": {
"PowerShell": {
"source": "PowerShell",
"args": ["-NoExit", "-Command", "chcp 936 | Out-Null"]
}
}
}

View File

@@ -1,5 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration debug="false">
<!-- 与 application-*.yml 中 logging.charset 对齐Windows 集成终端默认 GBK -->
<springProperty scope="context" name="CONSOLE_LOG_CHARSET" source="logging.charset.console" defaultValue="GBK"/>
<springProperty scope="context" name="FILE_LOG_CHARSET" source="logging.charset.file" defaultValue="UTF-8"/>
<!--定义日志文件的存储地址 -->
<property name="LOG_HOME" value="../logs" />
@@ -10,6 +14,7 @@
<!--格式化输出:%d表示日期%thread表示线程名%-5level级别从左显示5个字符宽度%msg日志消息%n是换行符
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50}:%L - %msg%n</pattern>-->
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %highlight(%-5level) %cyan(%logger{50}:%L) - %msg%n</pattern>
<charset>${CONSOLE_LOG_CHARSET}</charset>
</encoder>
</appender>
@@ -25,6 +30,7 @@
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<!--格式化输出:%d表示日期%thread表示线程名%-5level级别从左显示5个字符宽度%msg日志消息%n是换行符 -->
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50}:%L - %msg%n</pattern>
<charset>${FILE_LOG_CHARSET}</charset>
</encoder>
</appender>