lhotari commented on code in PR #25098:
URL: https://github.com/apache/pulsar/pull/25098#discussion_r2634844987
##########
pulsar-broker/src/test/java/org/apache/pulsar/broker/service/SystemTopicBasedTopicPoliciesServiceTest.java:
##########
@@ -480,18 +476,12 @@ public void
testCreateNamespaceEventsSystemTopicFactoryException() throws Except
@Test
public void
testPrepareInitPoliciesCacheAsyncThrowExceptionAfterCreateReader() throws
Exception {
// catch the log output in SystemTopicBasedTopicPoliciesService
- Logger logger = (Logger)
LogManager.getLogger(SystemTopicBasedTopicPoliciesService.class);
- List<String> logMessages = new ArrayList<>();
- AbstractAppender appender = new AbstractAppender("TestAppender", null,
null) {
- @Override
- public void append(LogEvent event) {
- logMessages.add(event.getMessage().getFormattedMessage());
- }
- };
- appender.start();
- logger.addAppender(appender);
+ @Cleanup
+ TestLogAppender testLogAppender =
+
TestLogAppender.create(Optional.of("SystemTopicBasedTopicPoliciesService"));
Review Comment:
I think that this would attach to the root logger since
`SystemTopicBasedTopicPoliciesService` wouldn't be found. The logger name is
the full class name.
Please improve `TestLogAppender` and add a `.create(Class<?>
loggerNameClass)` method to simplify the creation. It could delegate to
`create(Optional.of(loggerNameClass.getName()))`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]