zyx 1 年之前
父節點
當前提交
4fc7a3d702
共有 3 個文件被更改,包括 12 次插入8 次删除
  1. 4 4
      build.gradle
  2. 2 4
      src/main/java/org/example/AliyunLogger.java
  3. 6 0
      src/main/java/org/example/Daka.java

+ 4 - 4
build.gradle

@@ -4,8 +4,10 @@ plugins {
 
 group 'org.example'
 version '1.0-SNAPSHOT'
-sourceCompatibility = 8
-tasks.withType(JavaCompile).configureEach {
+sourceCompatibility = 17
+targetCompatibility = 17
+
+tasks.withType(JavaCompile) {
     options.encoding = "UTF-8"
 }
 
@@ -26,7 +28,6 @@ dependencies {
 }
 
 
-
 jar {
     manifest {
         attributes(
@@ -46,4 +47,3 @@ test {
     useJUnitPlatform()
 }
 
-targetCompatibility = JavaVersion.VERSION_16

+ 2 - 4
src/main/java/org/example/AliyunLogger.java

@@ -19,9 +19,7 @@ public class AliyunLogger {
     private final String app = "daka";
 
 
-    public void init() {
-
-
+    public AliyunLogger() {
         ProducerConfig producerConfig = new ProducerConfig();
         producerConfig.setBatchSizeThresholdInBytes(3 * 1024 * 1024);
         producerConfig.setBatchCountThreshold(40960);
@@ -34,6 +32,7 @@ public class AliyunLogger {
         Runtime.getRuntime().addShutdownHook(new Thread(this::close));
     }
 
+
     public void debug(Object... kv) {
         try {
             LogItem item = log(kv);
@@ -118,7 +117,6 @@ public class AliyunLogger {
 
     public static void main(String[] args) {
         AliyunLogger aliyunLogger = new AliyunLogger();
-        aliyunLogger.init();
 
         aliyunLogger.info("msg", "123");
         aliyunLogger.info("msg", 1);

+ 6 - 0
src/main/java/org/example/Daka.java

@@ -1,5 +1,9 @@
 package org.example;
 
+import com.aliyun.openservices.aliyun.log.producer.LogProducer;
+import com.aliyun.openservices.aliyun.log.producer.Producer;
+import com.aliyun.openservices.aliyun.log.producer.ProducerConfig;
+import com.aliyun.openservices.aliyun.log.producer.ProjectConfig;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import lombok.SneakyThrows;
 import org.apache.commons.io.IOUtils;
@@ -34,6 +38,8 @@ public class Daka {
     @SneakyThrows
     public static void main(String[] args) {
 
+
+
         String publicKeyStr = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQChDzcjw/rWgFwnxunbKp7/4e8w\n" +
                 "/UmXx2jk6qEEn69t6N2R1i/LmcyDT1xr/T2AHGOiXNQ5V8W4iCaaeNawi7aJaRht\n" +
                 "Vx1uOH/2U378fscEESEG8XDqll0GCfB1/TjKI2aitVSzXOtRs8kYgGU78f7VmDNg\n" +