Top Description Inners Fields Constructors Methods
org.apache.logging.log4j.jul

public Class DefaultLevelConverter

extends Object
implements LevelConverter
Class Inheritance
All Implemented Interfaces
org.apache.logging.log4j.jul.LevelConverter
Imports
java.io.Serializable, java.util.ArrayList, .Collections, .Comparator, .IdentityHashMap, .List, .Map, java.util.concurrent.ConcurrentHashMap, .ConcurrentMap, org.apache.logging.log4j.Level

Default implementation of LevelConverter strategy.

Since 2.4, supports custom JUL levels by mapping them to their closest mapped neighbour.

Since
2.1

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class

Field Summary

Modifier and TypeField and Description
private final ConcurrentMap<Level, Level>
private final Map<Level, Level>
private final List<Level>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private long
distance(final Level javaLevel, final Level customJavaLevel)

private void
mapJulToLog4j(final Level julLevel, final Level level)

private void
mapLog4jToJul(final Level level, final Level julLevel)

private Level
nearestLevel(final Level customJavaLevel)

public Level
toJavaLevel(final Level
Log4j Level to convert.
level
)

Implements org.apache.logging.log4j.jul.LevelConverter.toJavaLevel.

Converts a Log4j logging Level to a JDK logging Level.

public Level
toLevel(final Level
JDK Level to convert, may be null per the JUL specification.
javaLevel
)

Implements org.apache.logging.log4j.jul.LevelConverter.toLevel.

Converts a JDK logging Level to a Log4j logging Level.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

julToLog4jback to summary
private final ConcurrentMap<Level, Level> julToLog4j
log4jToJulback to summary
private final Map<Level, Level> log4jToJul
sortedJulLevelsback to summary
private final List<Level> sortedJulLevels

Constructor Detail

DefaultLevelConverterback to summary
public DefaultLevelConverter()

Method Detail

distanceback to summary
private long distance(final Level javaLevel, final Level customJavaLevel)
mapJulToLog4jback to summary
private void mapJulToLog4j(final Level julLevel, final Level level)
mapLog4jToJulback to summary
private void mapLog4jToJul(final Level level, final Level julLevel)
nearestLevelback to summary
private Level nearestLevel(final Level customJavaLevel)
toJavaLevelback to summary
public Level toJavaLevel(final Level level)

Implements org.apache.logging.log4j.jul.LevelConverter.toJavaLevel.

Doc from org.apache.logging.log4j.jul.LevelConverter.toJavaLevel.

Converts a Log4j logging Level to a JDK logging Level.

Parameters
level:Level

Log4j Level to convert.

Returns:Level

converted Level or null if the given level could not be converted.

Annotations
@Override
toLevelback to summary
public Level toLevel(final Level javaLevel)

Implements org.apache.logging.log4j.jul.LevelConverter.toLevel.

Doc from org.apache.logging.log4j.jul.LevelConverter.toLevel.

Converts a JDK logging Level to a Log4j logging Level.

Parameters
javaLevel:Level

JDK Level to convert, may be null per the JUL specification.

Returns:Level

converted Level or null if the given level could not be converted.

Annotations
@Override
org.apache.logging.log4j.jul back to summary

pack-priv final Class DefaultLevelConverter.JulLevelComparator

extends Object
implements Comparator<Level>, Serializable
Class Inheritance
  • java.lang.Object
  • org.apache.logging.log4j.jul.DefaultLevelConverter.JulLevelComparator
All Implemented Interfaces
java.io.Serializable, java.util.Comparator

Field Summary

Modifier and TypeField and Description
private static final long

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public int
compare(final Level
the first object to be compared.
level1
,
final Level
the second object to be compared.
level2
)

Implements java.util.Comparator.compare.

Compares its two arguments for order.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

serialVersionUIDback to summary
private static final long serialVersionUID

Constructor Detail

JulLevelComparatorback to summary
pack-priv JulLevelComparator()

Method Detail

compareback to summary
public int compare(final Level level1, final Level level2)

Implements java.util.Comparator.compare.

Doc from java.util.Comparator.compare.

Compares its two arguments for order. Returns a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.

The implementor must ensure that signum(compare(x, y)) == -signum(compare(y, x)) for all x and y. (This implies that compare(x, y) must throw an exception if and only if compare(y, x) throws an exception.)

The implementor must also ensure that the relation is transitive: ((compare(x, y)>0) && (compare(y, z)>0)) implies compare(x, z)>0.

Finally, the implementor must ensure that compare(x, y)==0 implies that signum(compare(x, z))==signum(compare(y, z)) for all z.

Parameters
level1:Level

the first object to be compared.

level2:Level

the second object to be compared.

Returns:int

a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.

Annotations
@Override