Skip to content

Commit a5ca784

Browse files
committed
Use slf4j instead of the apache log4j for logging tables
1 parent 7c6fe71 commit a5ca784

2 files changed

Lines changed: 16 additions & 15 deletions

File tree

warehouse/query-core/src/test/java/datawave/helpers/Output.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
import java.io.PrintStream;
44

5-
import org.apache.log4j.Level;
6-
import org.apache.log4j.Logger;
5+
import org.slf4j.Logger;
6+
import org.slf4j.event.Level;
77

88
public interface Output {
99

@@ -15,25 +15,25 @@ default void writeln(String line) {
1515

1616
void flush();
1717

18-
class ApacheLog4JOutput implements Output {
18+
class Slf4jOutput implements Output {
1919

2020
private final StringBuilder sb = new StringBuilder();
2121
private final Logger log;
2222
private final Level level;
2323

24-
public static ApacheLog4JOutput info(Logger log) {
25-
return new ApacheLog4JOutput(log, Level.INFO);
24+
public static Slf4jOutput info(Logger log) {
25+
return new Slf4jOutput(log, Level.INFO);
2626
}
2727

28-
public static ApacheLog4JOutput debug(Logger log) {
29-
return new ApacheLog4JOutput(log, Level.DEBUG);
28+
public static Slf4jOutput debug(Logger log) {
29+
return new Slf4jOutput(log, Level.DEBUG);
3030
}
3131

32-
public static ApacheLog4JOutput trace(Logger log) {
33-
return new ApacheLog4JOutput(log, Level.TRACE);
32+
public static Slf4jOutput trace(Logger log) {
33+
return new Slf4jOutput(log, Level.TRACE);
3434
}
3535

36-
public ApacheLog4JOutput(Logger log, Level level) {
36+
public Slf4jOutput(Logger log, Level level) {
3737
this.log = log;
3838
this.level = level;
3939
}
@@ -45,7 +45,7 @@ public void write(String line) {
4545

4646
@Override
4747
public void flush() {
48-
log.log(level, sb.toString());
48+
log.atLevel(level).log(sb.toString());
4949
sb.setLength(0);
5050
}
5151
}

warehouse/query-core/src/test/java/datawave/helpers/PrintUtility.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
import org.apache.accumulo.core.data.Value;
1919
import org.apache.accumulo.core.security.Authorizations;
2020
import org.apache.hadoop.io.WritableUtils;
21-
import org.apache.log4j.Logger;
21+
import org.slf4j.Logger;
22+
import org.slf4j.LoggerFactory;
2223

2324
import com.clearspring.analytics.stream.cardinality.HyperLogLogPlus;
2425

@@ -39,7 +40,7 @@
3940
*/
4041
public final class PrintUtility {
4142

42-
private static final Logger log = Logger.getLogger(PrintUtility.class);
43+
private static final Logger log = LoggerFactory.getLogger(PrintUtility.class);
4344

4445
private static final DateTimeFormatter ISO_DATE_TIME_MILLIS = DateTimeFormatter.ofPattern("yyyyMMdd-HHmmss").withZone(ZoneId.systemDefault());
4546

@@ -359,7 +360,7 @@ public void writeTable(final AccumuloClient client, final Authorizations authori
359360
public static void printTableToLogDebug(final AccumuloClient client, final Authorizations authorizations, final String tableName, final TableWriter writer)
360361
throws TableNotFoundException {
361362
if (log.isDebugEnabled()) {
362-
printTable(client, authorizations, tableName, writer, Output.ApacheLog4JOutput.debug(log));
363+
printTable(client, authorizations, tableName, writer, Output.Slf4jOutput.debug(log));
363364
}
364365
}
365366

@@ -468,7 +469,7 @@ private static String decodeEdgeMetadata(Value value) {
468469
}
469470

470471
/**
471-
* Decode the given value as an compressed and encoded document.
472+
* Decode the given value as a compressed and encoded document.
472473
*/
473474
private static String decodeDocument(Value value) {
474475
try {

0 commit comments

Comments
 (0)