Browse Source

add log support setting

张泳健 5 years ago
parent
commit
7dc5a82137

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

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

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

1
 package me.yuxiaoyao.config.log;
1
 package me.yuxiaoyao.config.log;
2
 
2
 
3
-import ch.qos.logback.classic.util.ContextInitializer;
4
 import me.yuxiaoyao.config.loader.ConfigLoader;
3
 import me.yuxiaoyao.config.loader.ConfigLoader;
5
 import org.slf4j.bridge.SLF4JBridgeHandler;
4
 import org.slf4j.bridge.SLF4JBridgeHandler;
6
 
5
 
23
         if (profile == null) {
22
         if (profile == null) {
24
             return;
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
         if (file.exists()) {
26
         if (file.exists()) {
28
-            System.setProperty(ContextInitializer.CONFIG_FILE_PROPERTY, file.getAbsolutePath());
27
+            System.setProperty("logback.configurationFile", file.getAbsolutePath());
29
             return;
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
         if (file.exists()) {
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
 }