Optimize project structure, add log4j2.

This commit is contained in:
2022-06-03 14:22:23 +08:00
parent c0d30b0a30
commit 53fd9ddf7a
45 changed files with 438 additions and 40 deletions

View File

@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager">
<output url="file://$MODULE_DIR$/../../build/classes/java/main" />
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/resources" type="java-resource" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module" module-name="ClassroomInteraction.Library.main" />
<orderEntry type="library" name="log4j-core-2.17.2" level="project" />
<orderEntry type="library" name="log4j-api-2.17.2" level="project" />
</component>
</module>

View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.cfive.classroom.teacher.MainWindow">
<grid id="27dc6" binding="rootPanel" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="20" y="20" width="500" height="400"/>
</constraints>
<properties/>
<border type="none"/>
<children/>
</grid>
</form>

View File

@@ -0,0 +1,23 @@
package com.cfive.classroom.teacher;
import com.cfive.classroom.library.net.Test;
import javax.swing.*;
public class MainWindow {
private JPanel rootPanel;
public static void main(String[] args) {
JFrame frame = new JFrame("MainWindow");
frame.setContentPane(new MainWindow().rootPanel);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setVisible(true);
Test.run();
com.cfive.classroom.library.database.Test.run();
System.out.println("This is a test");
}
}

View File

@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<Configuration>
<Properties>
<!-- 定义日志格式 -->
<Property name="log.pattern">[%d{DEFAULT}] [%t/%-5level] %logger{36}: %msg%n</Property>
<!-- 定义文件名变量 -->
<Property name="file.info.filename">logs/latest21.log</Property>
<Property name="file.info.pattern">logs/%d{yyyy-MM-dd}-%i.log.gz</Property>
</Properties>
<!-- 定义Appender即目的地 -->
<Appenders>
<!-- 定义输出到屏幕 -->
<Console name="console" target="SYSTEM_OUT">
<!-- 日志格式引用上面定义的log.pattern -->
<PatternLayout pattern="${log.pattern}" />
</Console>
<!-- 定义输出到文件,文件名引用上面定义的file.info.filename -->
<RollingFile name="file" bufferedIO="true" fileName="${file.info.filename}" filePattern="${file.info.pattern}">
<PatternLayout pattern="${log.pattern}" />
<Policies>
<!-- 根据文件大小自动切割日志 -->
<SizeBasedTriggeringPolicy size="1 MB" />
</Policies>
<!-- 保留最近10份 -->
<DefaultRolloverStrategy max="10" />
</RollingFile>
</Appenders>
<Loggers>
<Root level="all">
<!-- 对info级别的日志输出到console -->
<AppenderRef ref="console" level="all" />
<!-- 对info级别的日志输出到file即上面定义的RollingFile -->
<AppenderRef ref="file" level="all" />
</Root>
</Loggers>
</Configuration>