Skip to content

Commit

Permalink
Merge pull request #280 from apache/bugfix/267-UIMA-Log4jLogger_impl-…
Browse files Browse the repository at this point in the history
…not-compatible-with-log4j-2.18.0

Issue #267 - UIMA Log4jLogger_impl not compatible with log4j 2.18.0+
  • Loading branch information
reckart authored Jan 12, 2023
2 parents de4bde8 + 683a302 commit 03b3745
Showing 1 changed file with 2 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
*/
package org.apache.uima.util.impl;

import java.lang.reflect.Field;
import java.text.MessageFormat;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.MarkerManager;
import org.apache.logging.log4j.core.Filter;
import org.apache.logging.log4j.core.Filter.Result;
import org.apache.logging.log4j.core.LogEvent;
Expand All @@ -42,7 +42,6 @@
*/
public class Log4jLogger_impl extends Logger_common_impl {

final static private Object[] zeroLengthArray = new Object[0];
/**
* <p>
* Markers that are for marking levels not supported by log4j.
Expand Down Expand Up @@ -246,19 +245,7 @@ private static org.apache.logging.log4j.Marker m(Marker m) {
return null;
}

Field markerField = null;
try {
markerField = m.getClass().getDeclaredField("marker");
markerField.setAccessible(true);
return (org.apache.logging.log4j.Marker) markerField.get(m);
} catch (Exception e) {
// Well, best effort...
return null;
} finally {
if (markerField != null) {
markerField.setAccessible(false);
}
}
return MarkerManager.getMarker(m.getName());
}

/*
Expand Down Expand Up @@ -412,5 +399,4 @@ public boolean isWarnEnabled() {
public boolean isWarnEnabled(Marker arg0) {
return logger.isWarnEnabled(m(arg0));
}

}

0 comments on commit 03b3745

Please sign in to comment.