Skip to content

Commit e208409

Browse files
author
杨松
committed
fix log replace slf4j by slf4j2 with springboot4.0.1
1 parent 223c918 commit e208409

File tree

7 files changed

+247
-217
lines changed

7 files changed

+247
-217
lines changed

apollo-client/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
</dependency>
9090
<dependency>
9191
<groupId>org.apache.logging.log4j</groupId>
92-
<artifactId>log4j-slf4j-impl</artifactId>
92+
<artifactId>log4j-slf4j2-impl</artifactId>
9393
<scope>test</scope>
9494
</dependency>
9595
<dependency>

apollo-core/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
</dependency>
6363
<dependency>
6464
<groupId>org.apache.logging.log4j</groupId>
65-
<artifactId>log4j-slf4j-impl</artifactId>
65+
<artifactId>log4j-slf4j2-impl</artifactId>
6666
<scope>test</scope>
6767
</dependency>
6868
<dependency>
Lines changed: 66 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,66 @@
1-
///*
2-
// * Copyright 2022 Apollo Authors
3-
// *
4-
// * Licensed under the Apache License, Version 2.0 (the "License");
5-
// * you may not use this file except in compliance with the License.
6-
// * You may obtain a copy of the License at
7-
// *
8-
// * http://www.apache.org/licenses/LICENSE-2.0
9-
// *
10-
// * Unless required by applicable law or agreed to in writing, software
11-
// * distributed under the License is distributed on an "AS IS" BASIS,
12-
// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
// * See the License for the specific language governing permissions and
14-
// * limitations under the License.
15-
// *
16-
// */
17-
//package com.ctrip.framework.apollo.core.utils;
18-
//
19-
//import com.ctrip.framework.test.tools.AloneRunner;
20-
//import com.ctrip.framework.test.tools.AloneWith;
21-
//import org.junit.Assert;
22-
//import org.junit.jupiter.api.Test;
23-
//import org.junit.runner.RunWith;
24-
//import org.junit.runners.JUnit4;
25-
//import org.slf4j.Logger;
26-
//import org.slf4j.LoggerFactory;
27-
//
28-
///**
29-
// * @author kl (http://kailing.pub)
30-
// * @since 2021/5/20
31-
// */
32-
//@RunWith(AloneRunner.class)
33-
//@AloneWith(JUnit4.class)
34-
//public class DeferredLogCacheTest {
35-
//
36-
// private final Logger logger = LoggerFactory.getLogger(getClass());
37-
// private static final String logMsg = "hello kl";
38-
//
39-
// @Test
40-
// public void testDeferredLogCacheMaxLogSize() {
41-
// for (int i = 0; i < 20000; i++) {
42-
// DeferredLogCache.info(logger, "DeferredLogUtilTest");
43-
// }
44-
// Assert.assertEquals(DeferredLogCache.logSize(), DeferredLogCache.MAX_LOG_SIZE);
45-
// }
46-
//
47-
// @Test
48-
// public void testDisableDeferred() {
49-
// DeferredLogCache.clear();
50-
// DeferredLogger.disable();
51-
// final Logger defaultLogger = DeferredLoggerFactory.getLogger(DeferredLoggerTest.class);
52-
// defaultLogger.info(logMsg);
53-
// defaultLogger.debug(logMsg);
54-
// defaultLogger.warn(logMsg);
55-
// Assert.assertEquals(0, DeferredLogCache.logSize());
56-
//
57-
// }
58-
//
59-
// @Test
60-
// public void testEnableDeferred() {
61-
// final Logger defaultLogger = DeferredLoggerFactory.getLogger(DeferredLoggerTest.class);
62-
// DeferredLogger.enable();
63-
//
64-
// defaultLogger.info(logMsg);
65-
// defaultLogger.debug(logMsg);
66-
// defaultLogger.warn(logMsg);
67-
// Assert.assertEquals(3, DeferredLogCache.logSize());
68-
// }
69-
//}
1+
/*
2+
* Copyright 2022 Apollo Authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*/
17+
package com.ctrip.framework.apollo.core.utils;
18+
19+
import com.ctrip.framework.test.tools.AloneExtension;
20+
import org.junit.Assert;
21+
import org.junit.jupiter.api.Test;
22+
import org.junit.jupiter.api.extension.ExtendWith;
23+
import org.slf4j.Logger;
24+
import org.slf4j.LoggerFactory;
25+
26+
/**
27+
* @author kl (http://kailing.pub)
28+
* @since 2021/5/20
29+
*/
30+
@ExtendWith(AloneExtension.class)
31+
public class DeferredLogCacheTest {
32+
33+
private final Logger logger = LoggerFactory.getLogger(getClass());
34+
private static final String logMsg = "hello kl";
35+
36+
@Test
37+
public void testDeferredLogCacheMaxLogSize() {
38+
for (int i = 0; i < 20000; i++) {
39+
DeferredLogCache.info(logger, "DeferredLogUtilTest");
40+
}
41+
Assert.assertEquals(DeferredLogCache.logSize(), DeferredLogCache.MAX_LOG_SIZE);
42+
}
43+
44+
@Test
45+
public void testDisableDeferred() {
46+
DeferredLogCache.clear();
47+
DeferredLogger.disable();
48+
final Logger defaultLogger = DeferredLoggerFactory.getLogger(DeferredLoggerTest.class);
49+
defaultLogger.info(logMsg);
50+
defaultLogger.debug(logMsg);
51+
defaultLogger.warn(logMsg);
52+
Assert.assertEquals(0, DeferredLogCache.logSize());
53+
54+
}
55+
56+
@Test
57+
public void testEnableDeferred() {
58+
final Logger defaultLogger = DeferredLoggerFactory.getLogger(DeferredLoggerTest.class);
59+
DeferredLogger.enable();
60+
61+
defaultLogger.info(logMsg);
62+
defaultLogger.debug(logMsg);
63+
defaultLogger.warn(logMsg);
64+
Assert.assertEquals(3, DeferredLogCache.logSize());
65+
}
66+
}
Lines changed: 45 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,45 @@
1-
///*
2-
// * Copyright 2022 Apollo Authors
3-
// *
4-
// * Licensed under the Apache License, Version 2.0 (the "License");
5-
// * you may not use this file except in compliance with the License.
6-
// * You may obtain a copy of the License at
7-
// *
8-
// * http://www.apache.org/licenses/LICENSE-2.0
9-
// *
10-
// * Unless required by applicable law or agreed to in writing, software
11-
// * distributed under the License is distributed on an "AS IS" BASIS,
12-
// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
// * See the License for the specific language governing permissions and
14-
// * limitations under the License.
15-
// *
16-
// */
17-
//package com.ctrip.framework.apollo.core.utils;
18-
//
19-
//import com.ctrip.framework.test.tools.AloneRunner;
20-
//import com.ctrip.framework.test.tools.AloneWith;
21-
//import org.junit.Assert;
22-
//import org.junit.jupiter.api.Test;
23-
//import org.junit.runner.RunWith;
24-
//import org.junit.runners.JUnit4;
25-
//
26-
///**
27-
// * @author kl (http://kailing.pub)
28-
// * @since 2021/5/21
29-
// */
30-
//@RunWith(AloneRunner.class)
31-
//@AloneWith(JUnit4.class)
32-
//public class DeferredLoggerStateTest {
33-
//
34-
// @Test
35-
// public void testDeferredState() {
36-
// Assert.assertFalse(DeferredLogger.isEnabled());
37-
//
38-
// DeferredLogger.enable();
39-
// Assert.assertTrue(DeferredLogger.isEnabled());
40-
//
41-
// DeferredLogger.replayTo();
42-
// Assert.assertFalse(DeferredLogger.isEnabled());
43-
//
44-
// DeferredLogger.enable();
45-
// Assert.assertFalse(DeferredLogger.isEnabled());
46-
// }
47-
//
48-
//}
1+
/*
2+
* Copyright 2022 Apollo Authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*/
17+
package com.ctrip.framework.apollo.core.utils;
18+
19+
import com.ctrip.framework.test.tools.AloneExtension;
20+
import org.junit.Assert;
21+
import org.junit.jupiter.api.Test;
22+
import org.junit.jupiter.api.extension.ExtendWith;
23+
24+
/**
25+
* @author kl (http://kailing.pub)
26+
* @since 2021/5/21
27+
*/
28+
@ExtendWith(AloneExtension.class)
29+
public class DeferredLoggerStateTest {
30+
31+
@Test
32+
public void testDeferredState() {
33+
Assert.assertFalse(DeferredLogger.isEnabled());
34+
35+
DeferredLogger.enable();
36+
Assert.assertTrue(DeferredLogger.isEnabled());
37+
38+
DeferredLogger.replayTo();
39+
Assert.assertFalse(DeferredLogger.isEnabled());
40+
41+
DeferredLogger.enable();
42+
Assert.assertFalse(DeferredLogger.isEnabled());
43+
}
44+
45+
}

0 commit comments

Comments
 (0)