Skip to content

Port log4j-to-slf4j changes from 2.x #2015

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

Merged
merged 1 commit into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
34 changes: 32 additions & 2 deletions log4j-to-slf4j/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,16 @@
<!--
~ OSGi and JPMS options
-->
<slf4j.support.bound>3</slf4j.support.bound>
<slf4j.support.range>[1.7,3)</slf4j.support.range>
<bnd-extra-package-options>
<!-- This bridge also support SLF4J 2.x -->
org.slf4j.*;version="${range;[==,${slf4j.support.bound})}"
org.slf4j.*;version="${slf4j.support.range}"
</bnd-extra-package-options>
<bnd-extra-module-options>
<!-- The module descriptor is in `META-INF/versions/9`
BND 6.x can not find it -->
org.slf4j;substitute="slf4j-api"
</bnd-extra-module-options>
</properties>
<dependencies>
<dependency>
Expand Down Expand Up @@ -95,4 +100,29 @@
</dependency>
</dependencies>

<build>
<plugins>
<!--
~ Unban Logback.
-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<executions>
<execution>
<id>ban-logging-dependencies</id>
<configuration>
<rules>
<bannedDependencies>
<includes>
<include>ch.qos.logback:*:*:*:test</include>
</includes>
</bannedDependencies>
</rules>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@
import org.slf4j.MarkerFactory;
import org.slf4j.spi.LocationAwareLogger;

/**
*
*/
public class SLF4JLogger extends AbstractLogger {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@
import org.apache.logging.log4j.spi.LoggerRegistry;
import org.slf4j.LoggerFactory;

/**
*
*/
public class SLF4JLoggerContext implements LoggerContext {
private final LoggerRegistry<ExtendedLogger> loggerRegistry = new LoggerRegistry<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@
import org.apache.logging.log4j.status.StatusLogger;
import org.apache.logging.log4j.util.LoaderUtil;

/**
*
*/
public class SLF4JLoggerContextFactory implements LoggerContextFactory {
private static final StatusLogger LOGGER = StatusLogger.getLogger();
private static final LoggerContext context = new SLF4JLoggerContext();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*/
package org.apache.logging.slf4j;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*;

Expand All @@ -43,7 +42,6 @@
@LoggerContextSource
public class LoggerTest {

private static final String STRING = "String";
// Log4j objects
private Logger logger;
// Logback objects
Expand Down Expand Up @@ -72,7 +70,7 @@ public void basicFlow() {

@Test
public void simpleFlow() {
logger.traceEntry(STRING);
logger.traceEntry("foo");
logger.traceExit(0);
assertThat(list.strList, hasSize(2));
}
Expand Down