feat: adding log4j2 config
This commit is contained in:
parent
99af707edc
commit
f0dcae301b
1
.gitignore
vendored
1
.gitignore
vendored
@ -127,3 +127,4 @@ fabric.properties
|
|||||||
.idea/caches/build_file_checksums.ser
|
.idea/caches/build_file_checksums.ser
|
||||||
|
|
||||||
run/
|
run/
|
||||||
|
gradle.properties
|
||||||
|
9
.idea/compiler.xml
generated
9
.idea/compiler.xml
generated
@ -1,6 +1,15 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="CompilerConfiguration">
|
<component name="CompilerConfiguration">
|
||||||
|
<annotationProcessing>
|
||||||
|
<profile name="Gradle Imported" enabled="true">
|
||||||
|
<outputRelativeToContentRoot value="true" />
|
||||||
|
<processorPath useClasspath="false">
|
||||||
|
<entry name="$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.projectlombok/lombok/1.18.34/ec547ef414ab1d2c040118fb9c1c265ada63af14/lombok-1.18.34.jar" />
|
||||||
|
</processorPath>
|
||||||
|
<module name="MyBot.main" />
|
||||||
|
</profile>
|
||||||
|
</annotationProcessing>
|
||||||
<bytecodeTargetLevel target="11" />
|
<bytecodeTargetLevel target="11" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
1
.idea/gradle.xml
generated
1
.idea/gradle.xml
generated
@ -1,5 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
|
<component name="GradleMigrationSettings" migrationVersion="1" />
|
||||||
<component name="GradleSettings">
|
<component name="GradleSettings">
|
||||||
<option name="linkedExternalProjectsSettings">
|
<option name="linkedExternalProjectsSettings">
|
||||||
<GradleProjectSettings>
|
<GradleProjectSettings>
|
||||||
|
9
.idea/modules.xml
generated
Normal file
9
.idea/modules.xml
generated
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/MyBot.iml" filepath="$PROJECT_DIR$/MyBot.iml" />
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/.idea/modules/MyBot.main.iml" filepath="$PROJECT_DIR$/.idea/modules/MyBot.main.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
8
.idea/modules/MyBot.main.iml
generated
Normal file
8
.idea/modules/MyBot.main.iml
generated
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module version="4">
|
||||||
|
<component name="AdditionalModuleElements">
|
||||||
|
<content url="file://$MODULE_DIR$/../../build/generated/sources/annotationProcessor/java/main">
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/../../build/generated/sources/annotationProcessor/java/main" isTestSource="false" generated="true" />
|
||||||
|
</content>
|
||||||
|
</component>
|
||||||
|
</module>
|
8
MyBot.iml
Normal file
8
MyBot.iml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module version="4">
|
||||||
|
<component name="AdditionalModuleElements">
|
||||||
|
<content url="file://$MODULE_DIR$" dumb="true">
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/run" />
|
||||||
|
</content>
|
||||||
|
</component>
|
||||||
|
</module>
|
@ -1,3 +1,4 @@
|
|||||||
# MyBot
|
# MyBot
|
||||||
|
|
||||||
一个基于Java的OneBot11兼容机器人框架
|
## 一个基于Java的OneBot11兼容机器人框架
|
||||||
|
#### A Java-based OneBot11-compatible robot framework
|
@ -1,19 +1,99 @@
|
|||||||
|
val projectName = rootProject.name
|
||||||
|
val groupName by extra("cn.wzpmc")
|
||||||
|
val projectArtifactId by extra("my-bot")
|
||||||
|
val projectVersion by extra("0.0.1-dev")
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id("java")
|
id("java")
|
||||||
|
id("maven-publish")
|
||||||
}
|
}
|
||||||
|
|
||||||
group = "cn.wzpmc"
|
group = groupName
|
||||||
version = "1.0-SNAPSHOT"
|
version = projectVersion
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
// https://mvnrepository.com/artifact/io.netty/netty-all
|
||||||
|
implementation("io.netty:netty-all:4.1.112.Final")
|
||||||
|
// https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-core
|
||||||
|
implementation("org.apache.logging.log4j:log4j-core:2.23.1")
|
||||||
|
// https://mvnrepository.com/artifact/com.alibaba.fastjson2/fastjson2
|
||||||
|
implementation("com.alibaba.fastjson2:fastjson2:2.0.52")
|
||||||
|
// https://mvnrepository.com/artifact/org.projectlombok/lombok
|
||||||
|
compileOnly("org.projectlombok:lombok:1.18.34")
|
||||||
|
annotationProcessor("org.projectlombok:lombok:1.18.34")
|
||||||
testImplementation(platform("org.junit:junit-bom:5.10.0"))
|
testImplementation(platform("org.junit:junit-bom:5.10.0"))
|
||||||
testImplementation("org.junit.jupiter:junit-jupiter")
|
testImplementation("org.junit.jupiter:junit-jupiter")
|
||||||
}
|
}
|
||||||
|
tasks.compileJava {
|
||||||
|
options.encoding = "UTF-8"
|
||||||
|
}
|
||||||
|
tasks.javadoc {
|
||||||
|
options.encoding = "UTF-8"
|
||||||
|
}
|
||||||
|
tasks.register<Jar>("javadocJar") {
|
||||||
|
archiveClassifier.set("javadoc")
|
||||||
|
from(tasks.named("javadoc"))
|
||||||
|
}
|
||||||
|
tasks.register<Jar>("sourcesJar") {
|
||||||
|
archiveClassifier.set("sources")
|
||||||
|
from(sourceSets.main.get().allSource)
|
||||||
|
}
|
||||||
|
publishing {
|
||||||
|
publications {
|
||||||
|
create<MavenPublication>("mavenJava") {
|
||||||
|
from(components["java"])
|
||||||
|
|
||||||
|
groupId = groupName
|
||||||
|
artifactId = projectArtifactId
|
||||||
|
version = projectVersion
|
||||||
|
artifact(tasks.named("javadocJar"))
|
||||||
|
artifact(tasks.named("sourcesJar"))
|
||||||
|
pom {
|
||||||
|
name.set(projectName)
|
||||||
|
description.set("A Java-based OneBot11-compatible robot framework")
|
||||||
|
|
||||||
|
licenses {
|
||||||
|
license {
|
||||||
|
name.set("The MIT License")
|
||||||
|
url.set("https://opensource.org/licenses/MIT")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
developers {
|
||||||
|
developer {
|
||||||
|
id.set("wzp")
|
||||||
|
name.set("wzp")
|
||||||
|
email.set("minecraftwzpmc@gmail.com")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
scm {
|
||||||
|
connection.set("scm:git:https://wzpmc.cn:3000/wzp/MyBot.git")
|
||||||
|
developerConnection.set("scm:git:https://wzpmc.cn:3000/wzp/MyBot.git")
|
||||||
|
url.set("https://wzpmc.cn:3000/wzp/MyBot")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
maven {
|
||||||
|
val releasesRepoUrl = uri("http://server.wzpmc.cn:8081/repository/maven-releases")
|
||||||
|
val snapshotsRepoUrl = uri("http://server.wzpmc.cn:8081/repository/maven-snapshots")
|
||||||
|
url = if (version.toString().endsWith("SNAPSHOT")) snapshotsRepoUrl else releasesRepoUrl
|
||||||
|
|
||||||
|
credentials {
|
||||||
|
username = project.findProperty("repo.user") as String? ?: ""
|
||||||
|
password = project.findProperty("repo.password") as String? ?: ""
|
||||||
|
}
|
||||||
|
isAllowInsecureProtocol = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
tasks.test {
|
tasks.test {
|
||||||
useJUnitPlatform()
|
useJUnitPlatform()
|
||||||
}
|
}
|
@ -1,2 +1,2 @@
|
|||||||
rootProject.name = "MyBot"
|
val projectName by extra("MyBot")
|
||||||
|
rootProject.name = projectName
|
@ -1,17 +1,10 @@
|
|||||||
package cn.wzpmc;
|
package cn.wzpmc;
|
||||||
|
|
||||||
//TIP 要<b>运行</b>代码,请按 <shortcut actionId="Run"/> 或
|
import lombok.extern.log4j.Log4j2;
|
||||||
// 点击装订区域中的 <icon src="AllIcons.Actions.Execute"/> 图标。
|
|
||||||
|
@Log4j2
|
||||||
public class Main {
|
public class Main {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
//TIP 当文本光标位于高亮显示的文本处时按 <shortcut actionId="ShowIntentionActions"/>
|
|
||||||
// 查看 IntelliJ IDEA 建议如何修正。
|
|
||||||
System.out.printf("Hello and welcome!");
|
|
||||||
|
|
||||||
for (int i = 1; i <= 5; i++) {
|
|
||||||
//TIP 按 <shortcut actionId="Debug"/> 开始调试代码。我们已经设置了一个 <icon src="AllIcons.Debugger.Db_set_breakpoint"/> 断点
|
|
||||||
// 但您始终可以通过按 <shortcut actionId="ToggleLineBreakpoint"/> 添加更多断点。
|
|
||||||
System.out.println("i = " + i);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
30
src/main/resources/log4j2.xml
Normal file
30
src/main/resources/log4j2.xml
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Configuration status="WARN" monitorInterval="30">
|
||||||
|
<Appenders>
|
||||||
|
<!-- 控制台输出 -->
|
||||||
|
<Console name="Console" target="SYSTEM_OUT">
|
||||||
|
<PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss} [%p] %c - %m%n"/>
|
||||||
|
<ThresholdFilter level="INFO" onMatch="ACCEPT" onMismatch="DENY"/>
|
||||||
|
</Console>
|
||||||
|
|
||||||
|
<!-- 文件输出 -->
|
||||||
|
<RollingFile name="File" fileName="./logs/latest.log"
|
||||||
|
filePattern="./logs/bot-%d{yyyy-MM-dd-HH-mm-ss}.log.gz">
|
||||||
|
<PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss} [%p] %c - %m%n"/>
|
||||||
|
<Policies>
|
||||||
|
<OnStartupTriggeringPolicy/>
|
||||||
|
<!-- 按日期滚动日志 -->
|
||||||
|
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
|
||||||
|
</Policies>
|
||||||
|
<DefaultRolloverStrategy fileIndex="max" max="7"/>
|
||||||
|
</RollingFile>
|
||||||
|
</Appenders>
|
||||||
|
|
||||||
|
<Loggers>
|
||||||
|
<!-- 根记录器配置 -->
|
||||||
|
<Root level="DEBUG">
|
||||||
|
<AppenderRef ref="Console"/>
|
||||||
|
<AppenderRef ref="File"/>
|
||||||
|
</Root>
|
||||||
|
</Loggers>
|
||||||
|
</Configuration>
|
7
src/main/resources/templates/config.yaml
Normal file
7
src/main/resources/templates/config.yaml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
websocket: "<Your WebSocket connection link, e.g: ws://127.0.0.1:3001/>"
|
||||||
|
authorization:
|
||||||
|
enable: false
|
||||||
|
token: "<If you enable authorization, you should fill in this>"
|
||||||
|
fallback:
|
||||||
|
command: "Command Not Found!"
|
||||||
|
errorUncaught: "Had an error while run command!"
|
Loading…
x
Reference in New Issue
Block a user