-
Notifications
You must be signed in to change notification settings - Fork 849
添加输出游戏调试日志选项 #4144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
添加输出游戏调试日志选项 #4144
Changes from 20 commits
9dae044
48db756
60fd9d6
4fbd571
24d197c
69f2712
124e2d6
55c79f8
ecf95fb
9404c7a
19ecf82
87728ec
2b3179f
194a39c
3999a39
146ef4d
2d4658e
34cbbc7
550a4b2
9d88777
92b6216
68bec2a
688e408
bd4b690
0aefe4f
8d770b6
e5cb44b
157305b
e75df3b
8b9e2c5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -459,6 +459,20 @@ public void setShowLogs(boolean showLogs) { | |||||||||||
| showLogsProperty.set(showLogs); | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| private final BooleanProperty showDebugLogsProperty = new SimpleBooleanProperty(this, "showDebugLogs", false); | ||||||||||||
|
|
||||||||||||
| public BooleanProperty showDebugLogsProperty() { | ||||||||||||
| return showDebugLogsProperty; | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
|
||||||||||||
| /** | |
| * True if debug level logging should be enabled in log4j2 configuration. | |
| */ |
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -64,6 +64,7 @@ public class LaunchOptions implements Serializable { | |||||||||||
| private Renderer renderer = Renderer.DEFAULT; | ||||||||||||
| private boolean useNativeGLFW; | ||||||||||||
| private boolean useNativeOpenAL; | ||||||||||||
| private boolean showDebugLog; | ||||||||||||
| private boolean daemon; | ||||||||||||
|
|
||||||||||||
| /** | ||||||||||||
|
|
@@ -282,6 +283,10 @@ public boolean isUseNativeOpenAL() { | |||||||||||
| return useNativeOpenAL; | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
|
||||||||||||
| /** | |
| * Whether to enable debug level logging output in log4j2 configuration. | |
| */ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -148,9 +148,14 @@ private Command generateCommandLine(Path nativeFolder) throws IOException { | |
| res.addDefault("-Dcom.sun.jndi.rmi.object.trustURLCodebase=", "false"); | ||
| res.addDefault("-Dcom.sun.jndi.cosnaming.object.trustURLCodebase=", "false"); | ||
|
|
||
| String formatMsgNoLookups = res.addDefault("-Dlog4j2.formatMsgNoLookups=", "true"); | ||
| if (!"-Dlog4j2.formatMsgNoLookups=false".equals(formatMsgNoLookups) && isUsingLog4j()) { | ||
| if (options.isShowDebugLog()) { | ||
| res.addDefault("-Dlog4j2.formatMsgNoLookups=", "false"); | ||
CiiLu marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| res.addDefault("-Dlog4j.configurationFile=", FileUtils.getAbsolutePath(getLog4jConfigurationFile())); | ||
| } else { | ||
| String formatMsgNoLookups = res.addDefault("-Dlog4j2.formatMsgNoLookups=", "true"); | ||
|
||
| if (!"-Dlog4j2.formatMsgNoLookups=false".equals(formatMsgNoLookups) && isUsingLog4j()) { | ||
| res.addDefault("-Dlog4j.configurationFile=", FileUtils.getAbsolutePath(getLog4jConfigurationFile())); | ||
| } | ||
| } | ||
|
|
||
| // Default JVM Args | ||
|
|
@@ -421,14 +426,23 @@ public Path getLog4jConfigurationFile() { | |
|
|
||
| public void extractLog4jConfigurationFile() throws IOException { | ||
| Path targetFile = getLog4jConfigurationFile(); | ||
| InputStream source; | ||
|
|
||
| StringBuilder sourcePathBuilder = new StringBuilder("/assets/game/log4j2-"); | ||
CiiLu marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| if (GameVersionNumber.asGameVersion(repository.getGameVersion(version)).compareTo("1.12") < 0) { | ||
| source = DefaultLauncher.class.getResourceAsStream("/assets/game/log4j2-1.7.xml"); | ||
| sourcePathBuilder.append("1.7"); | ||
| } else { | ||
| source = DefaultLauncher.class.getResourceAsStream("/assets/game/log4j2-1.12.xml"); | ||
| sourcePathBuilder.append("1.12"); | ||
| } | ||
|
|
||
| try (InputStream input = source) { | ||
|
|
||
| if (options.isShowDebugLog()) { | ||
| sourcePathBuilder.append("-debug"); | ||
| } | ||
|
|
||
| sourcePathBuilder.append(".xml"); | ||
| String sourcePath = sourcePathBuilder.toString(); | ||
|
|
||
| try (InputStream input = DefaultLauncher.class.getResourceAsStream(sourcePath)) { | ||
| Files.copy(input, targetFile, StandardCopyOption.REPLACE_EXISTING); | ||
|
Comment on lines
+441
to
442
|
||
| } | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <Configuration status="warn" packages=""> | ||
| <Appenders> | ||
| <Console name="SysOut" target="SYSTEM_OUT"> | ||
| <PatternLayout pattern="[%d{HH:mm:ss}] [%t/%level]: %msg{nolookups}%n" /> | ||
| </Console> | ||
| <Queue name="ServerGuiConsole"> | ||
| <PatternLayout pattern="[%d{HH:mm:ss} %level]: %msg{nolookups}%n" /> | ||
| </Queue> | ||
| <RollingRandomAccessFile name="File" fileName="logs/latest.log" filePattern="logs/%d{yyyy-MM-dd}-%i.log.gz"> | ||
| <PatternLayout pattern="[%d{HH:mm:ss}] [%t/%level] [%logger]: %msg{nolookups}%n"/> | ||
| <Policies> | ||
| <TimeBasedTriggeringPolicy/> | ||
| <OnStartupTriggeringPolicy/> | ||
| </Policies> | ||
| </RollingRandomAccessFile> | ||
| <RollingRandomAccessFile name="DebugFile" fileName="logs/debug.log" filePattern="logs/debug-%d{yyyy-MM-dd}-%i.log.gz"> | ||
| <PatternLayout pattern="[%d{yyyy-MM-dd HH:mm:ss}] [%t/%level] [%logger]: %msg{nolookups}%n"/> | ||
| <Policies> | ||
| <TimeBasedTriggeringPolicy/> | ||
| <OnStartupTriggeringPolicy/> | ||
| </Policies> | ||
| <DefaultRolloverStrategy max="999" fileIndex="min"/> | ||
| </RollingRandomAccessFile> | ||
| </Appenders> | ||
| <Loggers> | ||
| <Root level="all"> | ||
| <filters> | ||
| <MarkerFilter marker="NETWORK_PACKETS" onMatch="DENY" onMismatch="NEUTRAL"/> | ||
| </filters> | ||
| <AppenderRef ref="SysOut" level="info"/> | ||
| <AppenderRef ref="ServerGuiConsole" level="info"/> | ||
| <AppenderRef ref="File" level="info"/> | ||
| <AppenderRef ref="DebugFile" level="all"/> | ||
| </Root> | ||
| </Loggers> | ||
| </Configuration> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <Configuration status="WARN"> | ||
| <Appenders> | ||
| <Console name="SysOut" target="SYSTEM_OUT"> | ||
| <PatternLayout pattern="[%d{HH:mm:ss}] [%t/%level]: %msg%n" /> | ||
| </Console> | ||
| <Queue name="ServerGuiConsole"> | ||
| <PatternLayout pattern="[%d{HH:mm:ss} %level]: %msg%n" /> | ||
| </Queue> | ||
| <RollingRandomAccessFile name="File" fileName="logs/latest.log" filePattern="logs/%d{yyyy-MM-dd}-%i.log.gz"> | ||
| <PatternLayout pattern="[%d{HH:mm:ss}] [%t/%level] [%logger]: %msg%n"/> | ||
| <Policies> | ||
| <TimeBasedTriggeringPolicy/> | ||
| <OnStartupTriggeringPolicy/> | ||
| </Policies> | ||
| </RollingRandomAccessFile> | ||
| <RollingRandomAccessFile name="DebugFile" fileName="logs/debug.log" filePattern="logs/debug-%d{yyyy-MM-dd}-%i.log.gz"> | ||
| <PatternLayout pattern="[%d{yyyy-MM-dd HH:mm:ss}] [%t/%level] [%logger]: %msg%n"/> | ||
| <Policies> | ||
| <TimeBasedTriggeringPolicy/> | ||
| <OnStartupTriggeringPolicy/> | ||
| </Policies> | ||
| </RollingRandomAccessFile> | ||
| </Appenders> | ||
| <Loggers> | ||
| <Root level="all"> | ||
| <filters> | ||
| <MarkerFilter marker="NETWORK_PACKETS" onMatch="DENY" onMismatch="NEUTRAL"/> | ||
| </filters> | ||
| <AppenderRef ref="SysOut" level="info"/> | ||
| <AppenderRef ref="ServerGuiConsole" level="info"/> | ||
| <AppenderRef ref="File" level="info"/> | ||
| <AppenderRef ref="DebugFile" level="all"/> | ||
| </Root> | ||
| </Loggers> | ||
| </Configuration> |
Uh oh!
There was an error while loading. Please reload this page.