Skip to content

Add collectionName and databaseName attributes to MongoDbProvider #3467

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 28 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
770ca32
Backported changes from the 3.x branch to 2.x
jesmith17 Feb 15, 2025
821b77f
Fixed some details in unit tests
jesmith17 Feb 15, 2025
8c0e3c6
Improve configuration error handling of HttpAppender (#3438)
Suvrat1629 Feb 16, 2025
180b050
Removed wildcard imports from tests
jesmith17 Feb 16, 2025
67c70b9
Merge branch '2.x' of github.com:jesmith17/logging-log4j2 into jesmit…
vy Feb 17, 2025
82b30c5
Improve `database.adoc`
vy Feb 17, 2025
1c2bcf8
Fix changelog entry
vy Feb 17, 2025
140aa29
Fix XSD versions
vy Feb 17, 2025
8602d73
Revert changes to resources of old tests
vy Feb 17, 2025
eac41a5
Fixed formatting
jesmith17 Feb 18, 2025
01d0b81
Fixed constructors to prevent potential backwards compat issues
jesmith17 Feb 18, 2025
f328147
Rewmoving maven wrapper that got created locally to solve build issues
jesmith17 Feb 18, 2025
d79431b
Publish build scans to develocity.apache.org (#3396)
clayburn Feb 18, 2025
fdb3e7d
Fix null termination advice for SOA and JTL
vy Feb 18, 2025
81ba7a4
Bump org.apache.logging:logging-parent from 11.3.0 to 12.0.0 in /log4…
dependabot[bot] Feb 18, 2025
00eb8f4
Run reproducibility check after each deployment
ppkarwasz Oct 17, 2024
4276c2b
Run integration tests after each deployment (#3105)
ppkarwasz Feb 18, 2025
701845f
Fix revision to `2.25.0-SNAPSHOT`
ppkarwasz Feb 18, 2025
cb8c7ec
Fix Nexus URL for snapshots
ppkarwasz Feb 18, 2025
0a2566c
Update `org.apache.cassandra:cassandra-all` to version `3.11.19` (#3440)
asf-rm Feb 18, 2025
e4982fd
Activate `bom` profile in `log4j-bom`
ppkarwasz Feb 19, 2025
645502a
Add Nexus URL argument to `generate-email.sh` per `logging-parent` up…
vy Feb 19, 2025
8aaf288
Document `maven-compiler-plugin` override
vy Feb 19, 2025
0289d63
Update `org.mongodb:bson` to version `5.3.1` (#3409)
asf-rm Feb 19, 2025
530d850
Implement review feedback
vy Feb 19, 2025
0712cae
Restore `maven-wrapper.properties`
vy Feb 19, 2025
8eef677
Fix plugin names
vy Feb 19, 2025
2a052e1
Fix test resource files
vy Feb 20, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .github/generate-email.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ stderr() {

fail_for_invalid_args() {
stderr "Invalid arguments!"
stderr "Expected arguments: <vote|announce> <version> <commitId>"
stderr "Expected arguments: <vote|announce> <version> <commitId> <nexusUrl>"
exit 1
}

# Check arguments
[ $# -ne 3 ] && fail_for_invalid_args
[ $# -ne 4 ] && fail_for_invalid_args

# Constants
PROJECT_NAME="Apache Log4j"
Expand All @@ -43,6 +43,7 @@ PROJECT_SITE="https://logging.apache.org/$PROJECT_ID"
PROJECT_STAGING_SITE="${PROJECT_SITE/apache.org/staged.apache.org}"
PROJECT_REPO="https://github.com/apache/logging-log4j2"
COMMIT_ID="$3"
NEXUS_URL="$4"
PROJECT_DIST_URL="https://dist.apache.org/repos/dist/dev/logging/$PROJECT_ID/$PROJECT_VERSION"

# Check release notes file
Expand Down Expand Up @@ -71,7 +72,7 @@ Website: $PROJECT_STAGING_SITE/$PROJECT_VERSION/index.html
GitHub: $PROJECT_REPO
Commit: $COMMIT_ID
Distribution: $PROJECT_DIST_URL
Nexus: https://repository.apache.org/content/repositories/orgapachelogging-<FIXME>
Nexus: $NEXUS_URL
Signing key: 0x077e8893a6dcc33dd4a4d5b256e73ba9a0b592d0
Review kit: https://logging.apache.org/logging-parent/release-review-instructions.html

Expand Down
32 changes: 27 additions & 5 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,21 @@ jobs:

build:
if: github.actor != 'dependabot[bot]'
uses: apache/logging-parent/.github/workflows/build-reusable.yaml@rel/11.3.0
uses: apache/logging-parent/.github/workflows/build-reusable.yaml@rel/12.0.0
secrets:
DV_ACCESS_TOKEN: ${{ startsWith(github.ref_name, 'release/') && '' || secrets.GE_ACCESS_TOKEN }}
DV_ACCESS_TOKEN: ${{ startsWith(github.ref_name, 'release/') && '' || secrets.DEVELOCITY_ACCESS_KEY }}
with:
java-version: |
8
17
site-enabled: true
reproducibility-check-enabled: ${{ startsWith(github.ref_name, 'release/') }}
reproducibility-check-enabled: false
develocity-enabled: ${{ ! startsWith(github.ref_name, 'release/') }}

deploy-snapshot:
needs: build
if: github.repository == 'apache/logging-log4j2' && github.ref_name == '2.x'
uses: apache/logging-parent/.github/workflows/deploy-snapshot-reusable.yaml@rel/11.3.0
uses: apache/logging-parent/.github/workflows/deploy-snapshot-reusable.yaml@rel/12.0.0
# Secrets for deployments
secrets:
NEXUS_USERNAME: ${{ secrets.NEXUS_USER }}
Expand All @@ -57,7 +57,7 @@ jobs:
deploy-release:
needs: build
if: github.repository == 'apache/logging-log4j2' && startsWith(github.ref_name, 'release/')
uses: apache/logging-parent/.github/workflows/deploy-release-reusable.yaml@rel/11.3.0
uses: apache/logging-parent/.github/workflows/deploy-release-reusable.yaml@rel/12.0.0
# Secrets for deployments
secrets:
GPG_SECRET_KEY: ${{ secrets.LOGGING_GPG_SECRET_KEY }}
Expand All @@ -73,3 +73,25 @@ jobs:
8
17
project-id: log4j

verify-reproducibility:
needs: [ deploy-snapshot, deploy-release ]
if: ${{ always() && (needs.deploy-snapshot.result == 'success' || needs.deploy-release.result == 'success') }}
name: "verify-reproducibility (${{ needs.deploy-release.result == 'success' && needs.deploy-release.outputs.project-version || needs.deploy-snapshot.outputs.project-version }})"
uses: apache/logging-parent/.github/workflows/verify-reproducibility-reusable.yaml@rel/12.0.0
with:
nexus-url: ${{ needs.deploy-release.result == 'success' && needs.deploy-release.outputs.nexus-url || 'https://repository.apache.org/content/groups/snapshots' }}
# Encode the `runs-on` input as JSON array
runs-on: '["ubuntu-latest", "macos-latest", "windows-latest"]'

# Run integration-tests automatically after a snapshot or RC is published
integration-test:
needs: [ deploy-snapshot, deploy-release ]
if: ${{ always() && (needs.deploy-snapshot.result == 'success' || needs.deploy-release.result == 'success') }}
name: "integration-test (${{ needs.deploy-release.result == 'success' && needs.deploy-release.outputs.project-version || needs.deploy-snapshot.outputs.project-version }})"
uses: apache/logging-log4j-samples/.github/workflows/integration-test.yaml@main
with:
log4j-version: ${{ needs.deploy-release.result == 'success' && needs.deploy-release.outputs.project-version || needs.deploy-snapshot.outputs.project-version }}
log4j-repository-url: ${{ needs.deploy-release.result == 'success' && needs.deploy-release.outputs.nexus-url || needs.deploy-snapshot.outputs.nexus-url }}
# Use the `main` branch of `logging-log4j-samples`
samples-ref: 'refs/heads/main'
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ permissions: read-all
jobs:

analyze:
uses: apache/logging-parent/.github/workflows/codeql-analysis-reusable.yaml@rel/11.3.0
uses: apache/logging-parent/.github/workflows/codeql-analysis-reusable.yaml@rel/12.0.0
with:
java-version: |
8
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/deploy-site.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:

deploy-site-stg:
if: github.repository == 'apache/logging-log4j2' && github.ref_name == '2.x'
uses: apache/logging-parent/.github/workflows/deploy-site-reusable.yaml@rel/11.3.0
uses: apache/logging-parent/.github/workflows/deploy-site-reusable.yaml@rel/12.0.0
# Secrets for committing the generated site
secrets:
GPG_SECRET_KEY: ${{ secrets.LOGGING_GPG_SECRET_KEY }}
Expand All @@ -51,7 +51,7 @@ jobs:

deploy-site-pro:
if: github.repository == 'apache/logging-log4j2' && github.ref_name == '2.x-site-pro'
uses: apache/logging-parent/.github/workflows/deploy-site-reusable.yaml@rel/11.3.0
uses: apache/logging-parent/.github/workflows/deploy-site-reusable.yaml@rel/12.0.0
# Secrets for committing the generated site
secrets:
GPG_SECRET_KEY: ${{ secrets.LOGGING_GPG_SECRET_KEY }}
Expand Down Expand Up @@ -81,7 +81,7 @@ jobs:

deploy-site-rel:
needs: export-version
uses: apache/logging-parent/.github/workflows/deploy-site-reusable.yaml@rel/11.3.0
uses: apache/logging-parent/.github/workflows/deploy-site-reusable.yaml@rel/12.0.0
# Secrets for committing the generated site
secrets:
GPG_SECRET_KEY: ${{ secrets.LOGGING_GPG_SECRET_KEY }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/develocity-publish-build-scans.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,5 @@ jobs:
- name: Publish Build Scans
uses: gradle/develocity-actions/maven-publish-build-scan@b8d3a572314ffff3b940a2c1b7b384d4983d422d # 1.3
with:
develocity-url: 'https://ge.apache.org'
develocity-access-key: ${{ secrets.GE_ACCESS_TOKEN }}
develocity-url: 'https://develocity.apache.org'
develocity-access-key: ${{ secrets.DEVELOCITY_ACCESS_KEY }}
6 changes: 3 additions & 3 deletions .github/workflows/merge-dependabot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ jobs:

build:
if: github.repository == 'apache/logging-log4j2' && github.event_name == 'pull_request_target' && github.actor == 'dependabot[bot]'
uses: apache/logging-parent/.github/workflows/build-reusable.yaml@rel/11.3.0
uses: apache/logging-parent/.github/workflows/build-reusable.yaml@rel/12.0.0
secrets:
DV_ACCESS_TOKEN: ${{ secrets.GE_ACCESS_TOKEN }}
DV_ACCESS_TOKEN: ${{ secrets.DEVELOCITY_ACCESS_KEY }}
with:
java-version: |
8
Expand All @@ -42,7 +42,7 @@ jobs:

merge-dependabot:
needs: build
uses: apache/logging-parent/.github/workflows/merge-dependabot-reusable.yaml@rel/11.3.0
uses: apache/logging-parent/.github/workflows/merge-dependabot-reusable.yaml@rel/12.0.0
with:
java-version: 17
permissions:
Expand Down
16 changes: 16 additions & 0 deletions .logging-parent-bom-activator
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
##
This file activates the `flatten-bom` profile.
2 changes: 1 addition & 1 deletion .mvn/develocity.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<develocity>
<projectId>logging-log4j2</projectId>
<server>
<url>https://ge.apache.org</url>
<url>https://develocity.apache.org</url>
</server>
<buildScan>
<capture>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to you under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.logging.log4j.core.appender;

import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertThrows;

import java.net.MalformedURLException;
import java.net.URL;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.core.Layout;
import org.apache.logging.log4j.core.config.Configuration;
import org.apache.logging.log4j.core.config.DefaultConfiguration;
import org.apache.logging.log4j.core.config.Property;
import org.apache.logging.log4j.core.layout.JsonLayout;
import org.apache.logging.log4j.core.net.ssl.SslConfiguration;
import org.apache.logging.log4j.test.ListStatusListener;
import org.apache.logging.log4j.test.junit.UsingStatusListener;
import org.junit.jupiter.api.Test;

class HttpAppenderBuilderTest {

private HttpAppender.Builder<?> getBuilder() {
Configuration mockConfig = new DefaultConfiguration();
return HttpAppender.newBuilder().setConfiguration(mockConfig).setName("TestHttpAppender"); // Name is required
}

@Test
@UsingStatusListener
void testBuilderWithoutUrl(final ListStatusListener listener) throws Exception {
HttpAppender appender = HttpAppender.newBuilder()
.setConfiguration(new DefaultConfiguration())
.setName("TestAppender")
.setLayout(JsonLayout.createDefaultLayout()) // Providing a layout here
.build();

assertThat(listener.findStatusData(Level.ERROR))
.anyMatch(statusData ->
statusData.getMessage().getFormattedMessage().contains("HttpAppender requires URL to be set."));
}

@Test
@UsingStatusListener
void testBuilderWithUrlAndWithoutLayout(final ListStatusListener listener) throws Exception {
HttpAppender appender = HttpAppender.newBuilder()
.setConfiguration(new DefaultConfiguration())
.setName("TestAppender")
.setUrl(new URL("http://localhost:8080/logs"))
.build();

assertThat(listener.findStatusData(Level.ERROR)).anyMatch(statusData -> statusData
.getMessage()
.getFormattedMessage()
.contains("HttpAppender requires a layout to be set."));
}

@Test
void testBuilderWithValidConfiguration() throws Exception {
URL url = new URL("http://example.com");
Layout<?> layout = JsonLayout.createDefaultLayout();

HttpAppender.Builder<?> builder = getBuilder().setUrl(url).setLayout(layout);

HttpAppender appender = builder.build();
assertNotNull(appender, "HttpAppender should be created with valid configuration.");
}

@Test
void testBuilderWithCustomMethod() throws Exception {
URL url = new URL("http://example.com");
Layout<?> layout = JsonLayout.createDefaultLayout();
String customMethod = "PUT";

HttpAppender.Builder<?> builder =
getBuilder().setUrl(url).setLayout(layout).setMethod(customMethod);

HttpAppender appender = builder.build();
assertNotNull(appender, "HttpAppender should be created with a custom HTTP method.");
}

@Test
void testBuilderWithHeaders() throws Exception {
URL url = new URL("http://example.com");
Layout<?> layout = JsonLayout.createDefaultLayout();
Property[] headers = new Property[] {
Property.createProperty("Header1", "Value1"), Property.createProperty("Header2", "Value2")
};

HttpAppender.Builder<?> builder =
getBuilder().setUrl(url).setLayout(layout).setHeaders(headers);

HttpAppender appender = builder.build();
assertNotNull(appender, "HttpAppender should be created with headers.");
}

@Test
void testBuilderWithSslConfiguration() throws Exception {
URL url = new URL("https://example.com");
Layout<?> layout = JsonLayout.createDefaultLayout();

// Use real SslConfiguration instead of Mockito mock
SslConfiguration sslConfig = SslConfiguration.createSSLConfiguration(null, null, null, false);

HttpAppender.Builder<?> builder =
getBuilder().setUrl(url).setLayout(layout).setSslConfiguration(sslConfig);

HttpAppender appender = builder.build();
assertNotNull(appender, "HttpAppender should be created with SSL configuration.");
}

@Test
void testBuilderWithInvalidUrl() {
assertThrows(MalformedURLException.class, () -> new URL("invalid-url"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,15 @@
import org.apache.logging.log4j.core.config.plugins.PluginElement;
import org.apache.logging.log4j.core.config.plugins.validation.constraints.Required;
import org.apache.logging.log4j.core.net.ssl.SslConfiguration;
import org.apache.logging.log4j.status.StatusLogger;

/**
* Sends log events over HTTP.
*/
@Plugin(name = "Http", category = Node.CATEGORY, elementType = Appender.ELEMENT_TYPE, printObject = true)
public final class HttpAppender extends AbstractAppender {

private static final StatusLogger LOGGER = StatusLogger.getLogger();

/**
* Builds HttpAppender instances.
* @param <B> The type to build
*/
public static class Builder<B extends Builder<B>> extends AbstractAppender.Builder<B>
implements org.apache.logging.log4j.core.util.Builder<HttpAppender> {
Expand Down Expand Up @@ -70,6 +69,18 @@ public static class Builder<B extends Builder<B>> extends AbstractAppender.Build

@Override
public HttpAppender build() {
// Validate URL presence
if (url == null) {
LOGGER.error("HttpAppender requires URL to be set.");
return null; // Return null if URL is missing
}

// Validate layout presence
if (getLayout() == null) {
LOGGER.error("HttpAppender requires a layout to be set.");
return null; // Return null if layout is missing
}

final HttpManager httpManager = new HttpURLConnectionManager(
getConfiguration(),
getConfiguration().getLoggerContext(),
Expand All @@ -81,10 +92,12 @@ public HttpAppender build() {
headers,
sslConfiguration,
verifyHostname);

return new HttpAppender(
getName(), getLayout(), getFilter(), isIgnoreExceptions(), httpManager, getPropertyArray());
}

// Getter and Setter methods
public URL getUrl() {
return url;
}
Expand Down Expand Up @@ -149,9 +162,6 @@ public B setVerifyHostname(final boolean verifyHostname) {
}
}

/**
* @return a builder for a HttpAppender.
*/
@PluginBuilderFactory
public static <B extends Builder<B>> B newBuilder() {
return new Builder<B>().asBuilder();
Expand Down
2 changes: 1 addition & 1 deletion log4j-mongodb/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<!-- OSGi and JPMS options -->
<Fragment-Host>org.apache.logging.log4j.core</Fragment-Host>
<!-- Dependency versions -->
<mongodb.version>5.2.1</mongodb.version>
<mongodb.version>5.3.1</mongodb.version>
<slf4j2.version>2.0.16</slf4j2.version>
</properties>
<dependencyManagement>
Expand Down
Loading
Loading