Browse Source

add log support setting

张泳健 5 years ago
parent
commit
7dc5a82137

+ 0 - 5
configuration-loader/pom.xml View File

@@ -25,11 +25,6 @@
25 25
             <groupId>org.slf4j</groupId>
26 26
             <artifactId>log4j-over-slf4j</artifactId>
27 27
         </dependency>
28
-        <dependency>
29
-            <groupId>ch.qos.logback</groupId>
30
-            <artifactId>logback-classic</artifactId>
31
-            <scope>provided</scope>
32
-        </dependency>
33 28
 
34 29
         <!-- json -->
35 30
         <dependency>

+ 4 - 5
configuration-loader/src/main/java/me/yuxiaoyao/config/log/LogSetter.java View File

@@ -1,6 +1,5 @@
1 1
 package me.yuxiaoyao.config.log;
2 2
 
3
-import ch.qos.logback.classic.util.ContextInitializer;
4 3
 import me.yuxiaoyao.config.loader.ConfigLoader;
5 4
 import org.slf4j.bridge.SLF4JBridgeHandler;
6 5
 
@@ -23,14 +22,14 @@ public class LogSetter {
23 22
         if (profile == null) {
24 23
             return;
25 24
         }
26
-        File file = new File(ConfigLoader.DEFAULT_FILE_CONFIG_FOLDER + File.separator + basename + "-" + profile + "xml");
25
+        File file = new File(ConfigLoader.DEFAULT_FILE_CONFIG_FOLDER + File.separator + basename + "-" + profile + ".xml");
27 26
         if (file.exists()) {
28
-            System.setProperty(ContextInitializer.CONFIG_FILE_PROPERTY, file.getAbsolutePath());
27
+            System.setProperty("logback.configurationFile", file.getAbsolutePath());
29 28
             return;
30 29
         }
31
-        file = new File(ConfigLoader.DEFAULT_FILE_CONFIG_FOLDER + File.separator + basename + "xml");
30
+        file = new File(ConfigLoader.DEFAULT_FILE_CONFIG_FOLDER + File.separator + basename + ".xml");
32 31
         if (file.exists()) {
33
-            System.setProperty(ContextInitializer.CONFIG_FILE_PROPERTY, file.getAbsolutePath());
32
+            System.setProperty("logback.configurationFile", file.getAbsolutePath());
34 33
         }
35 34
     }
36 35
 }