ramanathan1504 commented on code in PR #4321:
URL: https://github.com/apache/logging-log4j2/pull/4321#discussion_r4065858258
##########
log4j-api/src/main/java/org/apache/logging/log4j/util/ProviderUtil.java:
##########
@@ -245,7 +245,10 @@ static Provider selectProvider(
final Comparator<Provider> comparator =
Comparator.comparing(Provider::getPriority);
switch (providers.size()) {
case 0:
- statusLogger.error("Log4j API could not find a logging
provider.");
+ statusLogger.error("Log4j API could not find a logging
provider.\n"
+ + "Log4j API will use Simple Logger by default.\n"
+ + "See
https://logging.apache.org/log4j/2.x/manual/installation.html "
Review Comment:
#3415 names the `#impl` section. The page root opens several screens above
it.
```suggestion
+ "See
https://logging.apache.org/log4j/2.x/manual/installation.html#impl "
```
##########
src/site/antora/modules/ROOT/pages/manual/installation.adoc:
##########
@@ -186,6 +186,8 @@ xref:manual/status-logger.adoc[Status Logger] to avoid its
unintentional usages:
----
2024-10-03T11:53:34.281462230Z main ERROR Log4j API could not find a logging
provider.
+Log4j API will use Simple Logger by default.
+See https://logging.apache.org/log4j/2.x/manual/installation.html for
instructions on how to configure Log4j API.
Review Comment:
Keeps the sample output identical to what the API prints.
```suggestion
See https://logging.apache.org/log4j/2.x/manual/installation.html#impl for
instructions on how to configure Log4j API.
```
##########
log4j-api-test/src/test/java/org/apache/logging/log4j/util/ProviderUtilTest.java:
##########
@@ -56,13 +57,16 @@ void setup() {
}
@Test
- void should_have_a_fallback_provider() {
+ void
should_log_diagnostic_and_use_simple_provider_when_no_provider_is_available() {
final PropertiesUtil properties = new PropertiesUtil(new Properties());
assertThat(ProviderUtil.selectProvider(properties, NO_PROVIDERS,
statusLogger))
.as("check selected provider")
- .isNotNull();
- // An error for the absence of providers
- assertHasErrorOrWarning(statusLogger);
+ .isInstanceOf(SimpleProvider.class);
+ assertThat(statusLogger.getEntries())
+ .contains(" ERROR Log4j API could not find a logging
provider.\n"
+ + "Log4j API will use Simple Logger by default.\n"
+ + "See
https://logging.apache.org/log4j/2.x/manual/installation.html "
Review Comment:
Same anchor as the source, so the assertion keeps matching.
```suggestion
+ "See
https://logging.apache.org/log4j/2.x/manual/installation.html#impl "
```
##########
src/changelog/.2.x.x/3415_improve_missing_provider_diagnostic.xml:
##########
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<entry xmlns="https://logging.apache.org/xml/ns"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ https://logging.apache.org/xml/ns
+ https://logging.apache.org/xml/ns/log4j-changelog-0.xsd"
+ type="changed">
+ <issue id="3415"
link="https://github.com/apache/logging-log4j2/issues/3415"/>
Review Comment:
```suggestion
<issue id="3415"
link="https://github.com/apache/logging-log4j2/issues/3415"/>
<issue id="4321"
link="https://github.com/apache/logging-log4j2/pull/4321"/>
```
--
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]