File tree 4 files changed +21
-22
lines changed
log4j2-adapter/src/main/resources
logback-adapter-12/src/main/java/com/alibaba/nacos/logger/adapter/logback12
4 files changed +21
-22
lines changed Original file line number Diff line number Diff line change 72
72
<artifactId >nacos-log4j2-adapter</artifactId >
73
73
<version >${project.version} </version >
74
74
</dependency >
75
-
76
- <dependency >
77
- <groupId >org.apache.logging.log4j</groupId >
78
- <artifactId >log4j-core</artifactId >
79
- <optional >true</optional >
80
- </dependency >
81
-
82
- <dependency >
83
- <groupId >org.apache.logging.log4j</groupId >
84
- <artifactId >log4j-api</artifactId >
85
- <optional >true</optional >
86
- </dependency >
87
-
88
- <dependency >
89
- <groupId >org.apache.logging.log4j</groupId >
90
- <artifactId >log4j-slf4j-impl</artifactId >
91
- <optional >true</optional >
92
- </dependency >
93
75
94
76
<dependency >
95
77
<artifactId >commons-codec</artifactId >
Original file line number Diff line number Diff line change 1
1
<?xml version =" 1.0" encoding =" UTF-8" ?>
2
2
<!--
3
- ~ Copyright 1999-2018 Alibaba Group Holding Ltd.
3
+ ~ Copyright 1999-2023 Alibaba Group Holding Ltd.
4
4
~
5
5
~ Licensed under the Apache License, Version 2.0 (the "License");
6
6
~ you may not use this file except in compliance with the License.
Original file line number Diff line number Diff line change 20
20
import ch .qos .logback .classic .Logger ;
21
21
import ch .qos .logback .classic .LoggerContext ;
22
22
import ch .qos .logback .classic .spi .LoggerContextListener ;
23
- import ch .qos .logback .core .CoreConstants ;
24
23
import com .alibaba .nacos .common .logging .NacosLoggingAdapter ;
25
24
import com .alibaba .nacos .common .logging .NacosLoggingProperties ;
26
25
import com .alibaba .nacos .common .utils .ResourceUtils ;
@@ -91,7 +90,7 @@ public void loadConfiguration(NacosLoggingProperties loggingProperties) {
91
90
String location = loggingProperties .getLocation ();
92
91
configurator .setLoggingProperties (loggingProperties );
93
92
LoggerContext loggerContext = loadConfigurationOnStart (location );
94
- if (loggerContext . getObject ( CoreConstants . RECONFIGURE_ON_CHANGE_TASK ) != null && hasNoListener (loggerContext )) {
93
+ if (hasNoListener (loggerContext )) {
95
94
addListener (loggerContext , location );
96
95
}
97
96
}
Original file line number Diff line number Diff line change @@ -71,7 +71,12 @@ public void configure(URL url) throws Exception {
71
71
URLConnection urlConnection = url .openConnection ();
72
72
urlConnection .setUseCaches (false );
73
73
in = urlConnection .getInputStream ();
74
- doConfigure (in , url .toExternalForm ());
74
+ if (hasNewDoConfigureApi ()) {
75
+ doConfigure (in , url .toExternalForm ());
76
+ } else {
77
+ // adapter old version of logback below 1.1.10
78
+ doConfigure (in );
79
+ }
75
80
} catch (IOException ioe ) {
76
81
String errMsg = "Could not open URL [" + url + "]." ;
77
82
addError (errMsg , ioe );
@@ -89,4 +94,17 @@ public void configure(URL url) throws Exception {
89
94
}
90
95
}
91
96
97
+ /**
98
+ * Since logback 1.1.10, Add new doConfigure API with sax systemId and use this API to do configure.
99
+ *
100
+ * @return {@code true} when logback is upper 1.1.10, otherwise {@code false}
101
+ */
102
+ private boolean hasNewDoConfigureApi () {
103
+ try {
104
+ this .getClass ().getMethod ("doConfigure" , InputStream .class , String .class );
105
+ return true ;
106
+ } catch (NoSuchMethodException e ) {
107
+ return false ;
108
+ }
109
+ }
92
110
}
You can’t perform that action at this time.
0 commit comments