Author: rgoers
Date: Sun Jan 26 19:34:49 2014
New Revision: 1561537
URL: http://svn.apache.org/r1561537
Log:
LOG4J2-41 - Add support for custom logging levels
Added:
logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/db/jpa/converter/LevelAttributeConverter.java
- copied, changed from r1561366,
logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/db/jpa/converter/MarkerAttributeConverter.java
logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/ExtendedLevelTest.java
logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/test/ExtendedLevels.java
logging/log4j/log4j2/trunk/log4j-core/src/test/resources/log4j-customLevel.xml
- copied, changed from r1561366,
logging/log4j/log4j2/trunk/log4j-core/src/test/resources/log4j-test1.xml
Modified:
logging/log4j/log4j2/trunk/log4j-1.2-api/src/main/java/org/apache/log4j/Category.java
logging/log4j/log4j2/trunk/log4j-1.2-api/src/test/java/org/apache/log4j/BasicConfigurationFactory.java
logging/log4j/log4j2/trunk/log4j-api/src/main/java/org/apache/logging/log4j/Level.java
logging/log4j/log4j2/trunk/log4j-api/src/main/java/org/apache/logging/log4j/status/StatusLogger.java
logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/db/jpa/BasicLogEventEntity.java
logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/BaseConfiguration.java
logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/jmx/LoggerConfigAdmin.java
logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/net/Severity.java
logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/HighlightConverter.java
logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/LevelPatternConverter.java
logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/BasicConfigurationFactory.java
logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/db/jpa/TestBaseEntity.java
logging/log4j/log4j2/trunk/log4j-core/src/test/resources/META-INF/persistence.xml
logging/log4j/log4j2/trunk/log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/SLF4JLogger.java
logging/log4j/log4j2/trunk/src/changes/changes.xml
Modified:
logging/log4j/log4j2/trunk/log4j-1.2-api/src/main/java/org/apache/log4j/Category.java
URL:
http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-1.2-api/src/main/java/org/apache/log4j/Category.java?rev=1561537&r1=1561536&r2=1561537&view=diff
==============================================================================
---
logging/log4j/log4j2/trunk/log4j-1.2-api/src/main/java/org/apache/log4j/Category.java
(original)
+++
logging/log4j/log4j2/trunk/log4j-1.2-api/src/main/java/org/apache/log4j/Category.java
Sun Jan 26 19:34:49 2014
@@ -31,6 +31,7 @@ import org.apache.logging.log4j.core.hel
import org.apache.logging.log4j.message.LocalizedMessage;
import org.apache.logging.log4j.message.Message;
import org.apache.logging.log4j.message.ObjectMessage;
+import org.apache.logging.log4j.Level.StdLevel;
/**
@@ -156,7 +157,10 @@ public class Category {
public final Level getEffectiveLevel() {
final org.apache.logging.log4j.Level level = logger.getLevel();
+ return getEffectiveLevel(StdLevel.getStdLevel(level));
+ }
+ private Level getEffectiveLevel(StdLevel level) {
switch (level) {
case TRACE:
return Level.TRACE;
Modified:
logging/log4j/log4j2/trunk/log4j-1.2-api/src/test/java/org/apache/log4j/BasicConfigurationFactory.java
URL:
http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-1.2-api/src/test/java/org/apache/log4j/BasicConfigurationFactory.java?rev=1561537&r1=1561536&r2=1561537&view=diff
==============================================================================
---
logging/log4j/log4j2/trunk/log4j-1.2-api/src/test/java/org/apache/log4j/BasicConfigurationFactory.java
(original)
+++
logging/log4j/log4j2/trunk/log4j-1.2-api/src/test/java/org/apache/log4j/BasicConfigurationFactory.java
Sun Jan 26 19:34:49 2014
@@ -21,6 +21,7 @@ import org.apache.logging.log4j.core.con
import org.apache.logging.log4j.core.config.Configuration;
import org.apache.logging.log4j.core.config.ConfigurationFactory;
import org.apache.logging.log4j.core.config.LoggerConfig;
+
import java.net.URI;
/**
@@ -51,7 +52,7 @@ public class BasicConfigurationFactory e
final LoggerConfig root = getRootLogger();
setName("BasicConfiguration");
final String levelName = System.getProperty(DEFAULT_LEVEL);
- final Level level = (levelName != null && Level.valueOf(levelName)
!= null) ? Level.valueOf(levelName) : Level.DEBUG;
+ final Level level = (levelName != null &&
Level.getLevel(levelName) != null) ? Level.getLevel(levelName) : Level.DEBUG;
root.setLevel(level);
}
Modified:
logging/log4j/log4j2/trunk/log4j-api/src/main/java/org/apache/logging/log4j/Level.java
URL:
http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-api/src/main/java/org/apache/logging/log4j/Level.java?rev=1561537&r1=1561536&r2=1561537&view=diff
==============================================================================
---
logging/log4j/log4j2/trunk/log4j-api/src/main/java/org/apache/logging/log4j/Level.java
(original)
+++
logging/log4j/log4j2/trunk/log4j-api/src/main/java/org/apache/logging/log4j/Level.java
Sun Jan 26 19:34:49 2014
@@ -16,104 +16,138 @@
*/
package org.apache.logging.log4j;
+import java.io.ObjectStreamException;
+import java.io.Serializable;
+import java.util.EnumSet;
import java.util.Locale;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
-/**
- * Levels used for identifying the severity of an event. Levels are organized
from most specific to least:
- * <ul>
- * <li>{@link #OFF} (most specific)</li>
- * <li>{@link #FATAL}</li>
- * <li>{@link #ERROR}</li>
- * <li>{@link #WARN}</li>
- * <li>{@link #INFO}</li>
- * <li>{@link #DEBUG}</li>
- * <li>{@link #TRACE}</li>
- * <li>{@link #ALL} (least specific)</li>
- * </ul>
- *
- * Typically, configuring a level in a filter or on a logger will cause
logging events of that level and those
- * that are more specific to pass through the filter.
- * A special level, {@link #ALL}, is guaranteed to capture all levels when
used in logging configurations.
- */
-public enum Level {
+public class Level implements Comparable<Level>, Serializable {
- /**
- * No events will be logged.
- */
- OFF(0),
+ private static final long serialVersionUID = 3077535362528045615L;
+ private static ConcurrentMap<String, Level> levels = new
ConcurrentHashMap<String, Level>();
+ private static Object constructorLock = new Object();
+ private static int ordinalCount = 0;
+
+ public static Level OFF = new Level("OFF", 0){};
+ public static Level FATAL = new Level("FATAL", 100);
+ public static Level ERROR = new Level("ERROR", 200);
+ public static Level WARN = new Level("WARN", 300);
+ public static Level INFO = new Level("INFO", 400);
+ public static Level DEBUG = new Level("DEBUG", 500);
+ public static Level TRACE = new Level("TRACE", 600);
+ public static Level ALL = new Level("ALL", Integer.MAX_VALUE);
+
+ public enum StdLevel {
+
+ /**
+ * No events will be logged.
+ */
+ OFF(Level.OFF.intLevel()),
+
+ /**
+ * A severe error that will prevent the application from continuing.
+ */
+ FATAL(Level.FATAL.intLevel()),
+
+ /**
+ * An error in the application, possibly recoverable.
+ */
+ ERROR(Level.ERROR.intLevel()),
+
+ /**
+ * An event that might possible lead to an error.
+ */
+ WARN(Level.WARN.intLevel()),
+
+ /**
+ * An event for informational purposes.
+ */
+ INFO(Level.INFO.intLevel()),
+
+ /**
+ * A general debugging event.
+ */
+ DEBUG(Level.DEBUG.intLevel()),
+
+ /**
+ * A fine-grained debug message, typically capturing the flow through
the application.
+ */
+ TRACE(Level.TRACE.intLevel()),
+
+ /**
+ * All events should be logged.
+ */
+ ALL(Level.ALL.intLevel());
- /**
- * A severe error that will prevent the application from continuing.
- */
- FATAL(100),
-
- /**
- * An error in the application, possibly recoverable.
- */
- ERROR(200),
- /**
- * An event that might possible lead to an error.
- */
- WARN(300),
+ private final int intLevel;
- /**
- * An event for informational purposes.
- */
- INFO(400),
+ private static final EnumSet<StdLevel> levelSet =
EnumSet.allOf(StdLevel.class);
- /**
- * A general debugging event.
- */
- DEBUG(500),
+ private StdLevel(final int val) {
+ intLevel = val;
+ }
- /**
- * A fine-grained debug message, typically capturing the flow through the
application.
- */
- TRACE(600),
+ /**
+ * Returns the integer value of the Level.
+ * @return the integer value of the Level.
+ */
+ public int intLevel() {
+ return intLevel;
+ }
- /**
- * All events should be logged.
- */
- ALL(Integer.MAX_VALUE);
+ /**
+ * Method to convert custom Levels into a StdLevel for conversion to
other systems.
+ * @param level The Level.
+ * @return The StdLevel.
+ */
+ public static StdLevel getStdLevel(Level level) {
+ StdLevel severityLevel = StdLevel.OFF;
+ for (StdLevel lvl : levelSet) {
+ if (lvl.intLevel() > level.intLevel()) {
+ break;
+ }
+ severityLevel = lvl;
+ }
+ return severityLevel;
+ }
+ }
+ private final String name;
private final int intLevel;
+ private final int ordinal;
- private Level(final int val) {
- intLevel = val;
+ protected Level(String name, int intLevel) {
+ if (name == null || name.length() == 0) {
+ throw new IllegalArgumentException("Illegal null Level constant");
+ }
+ if (intLevel < 0) {
+ throw new IllegalArgumentException("Illegal Level int less than
zero.");
+ }
+ this.name = name;
+ this.intLevel = intLevel;
+ synchronized(constructorLock) {
+ if (levels.containsKey(name)) {
+ Level level = levels.get(name);
+ if (level.intLevel() != intLevel) {
+ throw new IllegalArgumentException("Level " + name + " has
already been defined.");
+ }
+ ordinal = level.ordinal;
+ } else {
+ ordinal = ordinalCount++;
+ levels.put(name, this);
+ }
+ }
}
- /**
- * Converts the string passed as argument to a level. If the
- * conversion fails, then this method returns {@link #DEBUG}.
- *
- * @param sArg The name of the desired Level.
- * @return The Level associated with the String.
- */
- public static Level toLevel(final String sArg) {
- return toLevel(sArg, DEBUG);
+ public int intLevel() {
+ return this.intLevel;
}
- /**
- * Converts the string passed as argument to a level. If the
- * conversion fails, then this method returns the value of
- * <code>defaultLevel</code>.
- *
- * @param name The name of the desired Level.
- * @param defaultLevel The Level to use if the String is invalid.
- * @return The Level associated with the String.
- */
- public static Level toLevel(final String name, final Level defaultLevel) {
- if (name == null) {
- return defaultLevel;
- }
- final String cleanLevel = name.toUpperCase(Locale.ENGLISH);
- for (final Level level : values()) {
- if (level.name().equals(cleanLevel)) {
- return level;
- }
- }
- return defaultLevel;
+ public int ordinal() {
+ return this.ordinal;
}
/**
@@ -124,7 +158,7 @@ public enum Level {
* @return True if the passed Level is more specific or the same as this
Level.
*/
public boolean isAtLeastAsSpecificAs(final Level level) {
- return intLevel <= level.intLevel;
+ return this.intLevel <= level.intLevel;
}
/**
@@ -135,7 +169,7 @@ public enum Level {
* @return True if the passed Level is more specific or the same as this
Level.
*/
public boolean isAtLeastAsSpecificAs(final int level) {
- return intLevel <= level;
+ return this.intLevel <= level;
}
/**
@@ -144,7 +178,7 @@ public enum Level {
* @return True if the passed Level is more specific or the same as this
Level.
*/
public boolean lessOrEqual(final Level level) {
- return intLevel <= level.intLevel;
+ return this.intLevel <= level.intLevel;
}
/**
@@ -153,14 +187,104 @@ public enum Level {
* @return True if the passed Level is more specific or the same as this
Level.
*/
public boolean lessOrEqual(final int level) {
- return intLevel <= level;
+ return this.intLevel <= level;
+ }
+
+ @Override
+ @SuppressWarnings("CloneDoesntCallSuperClone")
+ public Level clone() throws CloneNotSupportedException {
+ throw new CloneNotSupportedException();
+ }
+
+ @Override
+ public int compareTo(Level other) {
+ return intLevel < other.intLevel ? -1 : (intLevel > other.intLevel ? 1
: 0);
+ }
+
+ @Override
+ public boolean equals(Object other) {
+ return other instanceof Level && other == this;
+ }
+
+ public Class<Level> getDeclaringClass() {
+ return Level.class;
+ }
+
+ @Override
+ public int hashCode() {
+ return this.name.hashCode();
+ }
+
+
+ public String name() {
+ return this.name;
+ }
+
+ @Override
+ public String toString() {
+ return this.name;
}
/**
- * Returns the integer value of the Level.
- * @return the integer value of the Level.
+ * Return the Level assoicated with the name or null if the Level cannot
be found.
+ * @param name The name of the Level.
+ * @return The Level or null.
*/
- public int intLevel() {
- return intLevel;
+ public static Level getLevel(String name) {
+ return levels.get(name);
+ }
+
+ /**
+ * Converts the string passed as argument to a level. If the
+ * conversion fails, then this method returns {@link #DEBUG}.
+ *
+ * @param sArg The name of the desired Level.
+ * @return The Level associated with the String.
+ */
+ public static Level toLevel(final String sArg) {
+ return toLevel(sArg, Level.DEBUG);
+ }
+
+ /**
+ * Converts the string passed as argument to a level. If the
+ * conversion fails, then this method returns the value of
+ * <code>defaultLevel</code>.
+ *
+ * @param name The name of the desired Level.
+ * @param defaultLevel The Level to use if the String is invalid.
+ * @return The Level associated with the String.
+ */
+ public static Level toLevel(final String name, final Level defaultLevel) {
+ if (name == null) {
+ return defaultLevel;
+ }
+ Level level = levels.get(name.toUpperCase(Locale.ENGLISH));
+ return level == null ? defaultLevel : level;
+ }
+
+ public static Level[] values() {
+ return Level.levels.values().toArray(new Level[Level.levels.size()]);
+ }
+
+
+ public static Level valueOf(String name) {
+ if (name == null) {
+ throw new IllegalArgumentException("Unknown level constant [" +
name + "].");
+ }
+ name = name.toUpperCase();
+ if (levels.containsKey(name)) {
+ return levels.get(name);
+ }
+ throw new IllegalArgumentException("Unknown level constant [" + name +
"].");
+ }
+
+ public static <T extends Enum<T>> T valueOf(Class<T> enumType, String
name) {
+ return Enum.valueOf(enumType, name);
+ }
+
+ // for deserialization
+ protected final Object readResolve() throws ObjectStreamException {
+ return Level.valueOf(this.name);
}
}
+
Modified:
logging/log4j/log4j2/trunk/log4j-api/src/main/java/org/apache/logging/log4j/status/StatusLogger.java
URL:
http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-api/src/main/java/org/apache/logging/log4j/status/StatusLogger.java?rev=1561537&r1=1561536&r2=1561537&view=diff
==============================================================================
---
logging/log4j/log4j2/trunk/log4j-api/src/main/java/org/apache/logging/log4j/status/StatusLogger.java
(original)
+++
logging/log4j/log4j2/trunk/log4j-api/src/main/java/org/apache/logging/log4j/status/StatusLogger.java
Sun Jan 26 19:34:49 2014
@@ -250,7 +250,8 @@ public final class StatusLogger extends
if (listeners.size() > 0) {
return listenersLevel >= level.intLevel();
}
- switch (level) {
+
+ switch (Level.StdLevel.getStdLevel(level)) {
case FATAL:
return logger.isFatalEnabled(marker);
case TRACE:
Modified:
logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/db/jpa/BasicLogEventEntity.java
URL:
http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/db/jpa/BasicLogEventEntity.java?rev=1561537&r1=1561536&r2=1561537&view=diff
==============================================================================
---
logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/db/jpa/BasicLogEventEntity.java
(original)
+++
logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/db/jpa/BasicLogEventEntity.java
Sun Jan 26 19:34:49 2014
@@ -29,6 +29,7 @@ import org.apache.logging.log4j.ThreadCo
import org.apache.logging.log4j.core.LogEvent;
import
org.apache.logging.log4j.core.appender.db.jpa.converter.ContextMapAttributeConverter;
import
org.apache.logging.log4j.core.appender.db.jpa.converter.ContextStackAttributeConverter;
+import
org.apache.logging.log4j.core.appender.db.jpa.converter.LevelAttributeConverter;
import
org.apache.logging.log4j.core.appender.db.jpa.converter.MarkerAttributeConverter;
import
org.apache.logging.log4j.core.appender.db.jpa.converter.MessageAttributeConverter;
import
org.apache.logging.log4j.core.appender.db.jpa.converter.StackTraceElementAttributeConverter;
@@ -92,8 +93,7 @@ public abstract class BasicLogEventEntit
* @return the level.
*/
@Override
- @Basic
- @Enumerated(EnumType.STRING)
+ @Convert(converter = LevelAttributeConverter.class)
public Level getLevel() {
return this.getWrappedEvent().getLevel();
}
Copied:
logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/db/jpa/converter/LevelAttributeConverter.java
(from r1561366,
logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/db/jpa/converter/MarkerAttributeConverter.java)
URL:
http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/db/jpa/converter/LevelAttributeConverter.java?p2=logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/db/jpa/converter/LevelAttributeConverter.java&p1=logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/db/jpa/converter/MarkerAttributeConverter.java&r1=1561366&r2=1561537&rev=1561537&view=diff
==============================================================================
---
logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/db/jpa/converter/MarkerAttributeConverter.java
(original)
+++
logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/db/jpa/converter/LevelAttributeConverter.java
Sun Jan 26 19:34:49 2014
@@ -16,52 +16,32 @@
*/
package org.apache.logging.log4j.core.appender.db.jpa.converter;
+import org.apache.logging.log4j.Level;
+import org.apache.logging.log4j.core.helpers.Strings;
+
import javax.persistence.AttributeConverter;
import javax.persistence.Converter;
-import org.apache.logging.log4j.Marker;
-import org.apache.logging.log4j.MarkerManager;
-import org.apache.logging.log4j.core.helpers.Strings;
-
/**
- * A JPA 2.1 attribute converter for {@link Marker}s in {@link
org.apache.logging.log4j.core.LogEvent}s. This
+ * A JPA 2.1 attribute converter for {@link org.apache.logging.log4j.Level}s
in {@link org.apache.logging.log4j.core.LogEvent}s. This
* converter is capable of converting both to and from {@link String}s.
*/
@Converter(autoApply = false)
-public class MarkerAttributeConverter implements AttributeConverter<Marker,
String> {
+public class LevelAttributeConverter implements AttributeConverter<Level,
String> {
@Override
- public String convertToDatabaseColumn(final Marker marker) {
- if (marker == null) {
+ public String convertToDatabaseColumn(final Level level) {
+ if (level == null) {
return null;
}
-
- final StringBuilder builder = new StringBuilder(marker.getName());
- Marker parent = marker.getParent();
- int levels = 0;
- boolean hasParent = false;
- while (parent != null) {
- levels++;
- hasParent = true;
- builder.append("[ ").append(parent.getName());
- parent = parent.getParent();
- }
- for (int i = 0; i < levels; i++) {
- builder.append(" ]");
- }
- if (hasParent) {
- builder.append(" ]");
- }
- return builder.toString();
+ return level.name();
}
@Override
- public Marker convertToEntityAttribute(final String s) {
+ public Level convertToEntityAttribute(final String s) {
if (Strings.isEmpty(s)) {
return null;
}
- final int bracket = s.indexOf("[");
-
- return bracket < 1 ? MarkerManager.getMarker(s) :
MarkerManager.getMarker(s.substring(0, bracket));
+ return Level.toLevel(s, null);
}
}
Modified:
logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/BaseConfiguration.java
URL:
http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/BaseConfiguration.java?rev=1561537&r1=1561536&r2=1561537&view=diff
==============================================================================
---
logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/BaseConfiguration.java
(original)
+++
logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/BaseConfiguration.java
Sun Jan 26 19:34:49 2014
@@ -19,6 +19,7 @@ package org.apache.logging.log4j.core.co
import java.io.Serializable;
import java.lang.annotation.Annotation;
import java.lang.reflect.Array;
+import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
@@ -139,6 +140,19 @@ public class BaseConfiguration extends A
@Override
public void start() {
pluginManager.collectPlugins();
+ PluginManager levelPlugins = new PluginManager("Level");
+ levelPlugins.collectPlugins();
+ Map<String, PluginType<?>> plugins = levelPlugins.getPlugins();
+ if (plugins != null) {
+ for (PluginType<?> type : plugins.values()) {
+ try {
+ // Cause the class to be initialized if it isn't already.
+ Class.forName(type.getPluginClass().getName(), true,
type.getPluginClass().getClassLoader());
+ } catch (Exception ex) {
+ LOGGER.error("Unable to initialize " +
type.getPluginClass().getName() + " due to " +
ex.getClass().getSimpleName() + ":" + ex.getMessage());
+ }
+ }
+ }
setup();
setupAdvertisement();
doConfigure();
@@ -323,8 +337,8 @@ public class BaseConfiguration extends A
root.addAppender(appender, null, null);
final String levelName =
PropertiesUtil.getProperties().getStringProperty(DefaultConfiguration.DEFAULT_LEVEL);
- final Level level = levelName != null && Level.valueOf(levelName) !=
null ?
- Level.valueOf(levelName) : Level.ERROR;
+ final Level level = levelName != null && Level.getLevel(levelName) !=
null ?
+ Level.getLevel(levelName) : Level.ERROR;
root.setLevel(level);
}
Modified:
logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/jmx/LoggerConfigAdmin.java
URL:
http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/jmx/LoggerConfigAdmin.java?rev=1561537&r1=1561536&r2=1561537&view=diff
==============================================================================
---
logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/jmx/LoggerConfigAdmin.java
(original)
+++
logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/jmx/LoggerConfigAdmin.java
Sun Jan 26 19:34:49 2014
@@ -76,7 +76,7 @@ public class LoggerConfigAdmin implement
@Override
public void setLevel(final String level) {
- loggerConfig.setLevel(Level.valueOf(level));
+ loggerConfig.setLevel(Level.getLevel(level));
}
@Override
Modified:
logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/net/Severity.java
URL:
http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/net/Severity.java?rev=1561537&r1=1561536&r2=1561537&view=diff
==============================================================================
---
logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/net/Severity.java
(original)
+++
logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/net/Severity.java
Sun Jan 26 19:34:49 2014
@@ -18,6 +18,8 @@ package org.apache.logging.log4j.core.ne
import org.apache.logging.log4j.Level;
+import java.util.EnumSet;
+
/**
* Severity values used by the Syslog system.
*
@@ -80,6 +82,10 @@ public enum Severity {
* @return The matching Severity, or DEBUG if there is no match.
*/
public static Severity getSeverity(final Level level) {
+ return getSeverity(Level.StdLevel.getStdLevel(level));
+ }
+
+ private static Severity getSeverity(final Level.StdLevel level) {
switch (level) {
case ALL:
return DEBUG;
Modified:
logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/HighlightConverter.java
URL:
http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/HighlightConverter.java?rev=1561537&r1=1561536&r2=1561537&view=diff
==============================================================================
---
logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/HighlightConverter.java
(original)
+++
logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/HighlightConverter.java
Sun Jan 26 19:34:49 2014
@@ -17,7 +17,6 @@
package org.apache.logging.log4j.core.pattern;
import java.util.Arrays;
-import java.util.EnumMap;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
@@ -72,9 +71,9 @@ import org.apache.logging.log4j.core.lay
@ConverterKeys({ "highlight" })
public final class HighlightConverter extends LogEventPatternConverter
implements AnsiConverter {
- private static final EnumMap<Level, String> DEFAULT_STYLES = new
EnumMap<Level, String>(Level.class);
+ private static final Map<Level, String> DEFAULT_STYLES = new
HashMap<Level, String>();
- private static final EnumMap<Level, String> LOGBACK_STYLES = new
EnumMap<Level, String>(Level.class);
+ private static final Map<Level, String> LOGBACK_STYLES = new
HashMap<Level, String>();
private static final String STYLE_KEY = "STYLE";
@@ -82,7 +81,7 @@ public final class HighlightConverter ex
private static final String STYLE_KEY_LOGBACK = "LOGBACK";
- private static final Map<String, EnumMap<Level, String>> STYLES = new
HashMap<String, EnumMap<Level, String>>();
+ private static final Map<String, Map<Level, String>> STYLES = new
HashMap<String, Map<Level, String>>();
static {
// Default styles:
@@ -128,7 +127,7 @@ public final class HighlightConverter ex
* The second slot can optionally contain the style map.
* @return a new map
*/
- private static EnumMap<Level, String> createLevelStyleMap(final String[]
options) {
+ private static Map<Level, String> createLevelStyleMap(final String[]
options) {
if (options.length < 2) {
return DEFAULT_STYLES;
}
@@ -136,12 +135,12 @@ public final class HighlightConverter ex
String string = options[1].replaceAll(PatternParser.NO_CONSOLE_NO_ANSI
+ "=(true|false)", "");
//
final Map<String, String> styles = AnsiEscape.createMap(string, new
String[] {STYLE_KEY});
- final EnumMap<Level, String> levelStyles = new EnumMap<Level,
String>(DEFAULT_STYLES);
+ final Map<Level, String> levelStyles = new HashMap<Level,
String>(DEFAULT_STYLES);
for (final Map.Entry<String, String> entry : styles.entrySet()) {
final String key = entry.getKey().toUpperCase(Locale.ENGLISH);
final String value = entry.getValue();
if (STYLE_KEY.equalsIgnoreCase(key)) {
- final EnumMap<Level, String> enumMap =
STYLES.get(value.toUpperCase(Locale.ENGLISH));
+ final Map<Level, String> enumMap =
STYLES.get(value.toUpperCase(Locale.ENGLISH));
if (enumMap == null) {
LOGGER.error("Unknown level style: " + value + ". Use one
of " +
Arrays.toString(STYLES.keySet().toArray()));
@@ -149,7 +148,7 @@ public final class HighlightConverter ex
levelStyles.putAll(enumMap);
}
} else {
- final Level level = Level.valueOf(key);
+ final Level level = Level.toLevel(key);
if (level == null) {
LOGGER.error("Unknown level name: " + key + ". Use one of
" +
Arrays.toString(DEFAULT_STYLES.keySet().toArray()));
@@ -183,7 +182,7 @@ public final class HighlightConverter ex
return new HighlightConverter(formatters,
createLevelStyleMap(options));
}
- private final EnumMap<Level, String> levelStyles;
+ private final Map<Level, String> levelStyles;
private final List<PatternFormatter> patternFormatters;
@@ -193,7 +192,7 @@ public final class HighlightConverter ex
* @param patternFormatters
* The PatternFormatters to generate the text to manipulate.
*/
- private HighlightConverter(final List<PatternFormatter> patternFormatters,
final EnumMap<Level, String> levelStyles) {
+ private HighlightConverter(final List<PatternFormatter> patternFormatters,
final Map<Level, String> levelStyles) {
super("style", "style");
this.patternFormatters = patternFormatters;
this.levelStyles = levelStyles;
Modified:
logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/LevelPatternConverter.java
URL:
http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/LevelPatternConverter.java?rev=1561537&r1=1561536&r2=1561537&view=diff
==============================================================================
---
logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/LevelPatternConverter.java
(original)
+++
logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/LevelPatternConverter.java
Sun Jan 26 19:34:49 2014
@@ -16,8 +16,9 @@
*/
package org.apache.logging.log4j.core.pattern;
-import java.util.EnumMap;
+import java.util.HashMap;
import java.util.Locale;
+import java.util.Map;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.core.LogEvent;
@@ -37,19 +38,19 @@ public final class LevelPatternConverter
*/
private static final LevelPatternConverter INSTANCE = new
LevelPatternConverter(null);
- private final EnumMap<Level, String> levelMap;
+ private final Map<Level, String> levelMap;
/**
* Private constructor.
*/
- private LevelPatternConverter(final EnumMap<Level, String> map) {
+ private LevelPatternConverter(final Map<Level, String> map) {
super("Level", "level");
this.levelMap = map;
}
/**
* Obtains an instance of pattern converter.
- *
+ *
* @param options
* options, may be null. May contain a list of level names and
The value that should be displayed for the
* Level.
@@ -59,7 +60,7 @@ public final class LevelPatternConverter
if (options == null || options.length == 0) {
return INSTANCE;
}
- final EnumMap<Level, String> levelMap = new EnumMap<Level,
String>(Level.class);
+ final Map<Level, String> levelMap = new HashMap<Level, String>();
int length = Integer.MAX_VALUE; // More than the longest level name.
boolean lowerCase = false;
final String[] definitions = options[0].split(",");
@@ -98,7 +99,7 @@ public final class LevelPatternConverter
/**
* Returns the leftmost chars of the level name for the given level.
- *
+ *
* @param level
* The level
* @param length
@@ -128,30 +129,7 @@ public final class LevelPatternConverter
@Override
public String getStyleClass(final Object e) {
if (e instanceof LogEvent) {
- final Level level = ((LogEvent) e).getLevel();
-
- switch (level) {
- case TRACE:
- return "level trace";
-
- case DEBUG:
- return "level debug";
-
- case INFO:
- return "level info";
-
- case WARN:
- return "level warn";
-
- case ERROR:
- return "level error";
-
- case FATAL:
- return "level fatal";
-
- default:
- return "level " + ((LogEvent) e).getLevel().toString();
- }
+ return "level " + ((LogEvent)
e).getLevel().name().toLowerCase(Locale.ENGLISH);
}
return "level";
Modified:
logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/BasicConfigurationFactory.java
URL:
http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/BasicConfigurationFactory.java?rev=1561537&r1=1561536&r2=1561537&view=diff
==============================================================================
---
logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/BasicConfigurationFactory.java
(original)
+++
logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/BasicConfigurationFactory.java
Sun Jan 26 19:34:49 2014
@@ -21,6 +21,7 @@ import org.apache.logging.log4j.core.con
import org.apache.logging.log4j.core.config.Configuration;
import org.apache.logging.log4j.core.config.ConfigurationFactory;
import org.apache.logging.log4j.core.config.LoggerConfig;
+
import java.net.URI;
/**
@@ -51,7 +52,7 @@ public class BasicConfigurationFactory e
final LoggerConfig root = getRootLogger();
final String l = System.getProperty(DEFAULT_LEVEL);
- final Level level = (l != null && Level.valueOf(l) != null) ?
Level.valueOf(l) : Level.ERROR;
+ final Level level = (l != null && Level.getLevel(l) != null) ?
Level.getLevel(l) : Level.ERROR;
root.setLevel(level);
}
}
Added:
logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/ExtendedLevelTest.java
URL:
http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/ExtendedLevelTest.java?rev=1561537&view=auto
==============================================================================
---
logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/ExtendedLevelTest.java
(added)
+++
logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/ExtendedLevelTest.java
Sun Jan 26 19:34:49 2014
@@ -0,0 +1,95 @@
+/*
+ * 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;
+
+import org.apache.logging.log4j.Level;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.core.config.Configuration;
+import org.apache.logging.log4j.core.config.ConfigurationFactory;
+import org.apache.logging.log4j.status.StatusLogger;
+import org.apache.logging.log4j.test.ExtendedLevels;
+import org.apache.logging.log4j.test.appender.ListAppender;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.util.List;
+import java.util.Map;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+/**
+ *
+ */
+public class ExtendedLevelTest {
+
+ private static final String CONFIG = "log4j-customLevel.xml";
+ private static LoggerContext ctx;
+ private static ListAppender list1;
+ private static ListAppender list2;
+
+ @BeforeClass
+ public static void setupClass() {
+ System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY,
CONFIG);
+ ctx = (LoggerContext) LogManager.getContext(false);
+ }
+
+ @AfterClass
+ public static void cleanupClass() {
+ System.clearProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY);
+ ctx.reconfigure();
+ StatusLogger.getLogger().reset();
+ }
+
+ @Before
+ public void before() {
+ Configuration config = ctx.getConfiguration();
+ for (final Map.Entry<String, Appender> entry :
config.getAppenders().entrySet()) {
+ if (entry.getKey().equals("List1")) {
+ list1 = (ListAppender) entry.getValue();
+ } else if (entry.getKey().equals("List2")) {
+ list2 = (ListAppender) entry.getValue();
+ }
+ }
+ assertNotNull("No List1 Appender", list1);
+ assertNotNull("No List2 Appender", list2);
+ list1.clear();
+ list2.clear();
+ }
+
+ @Test
+ public void testLevelLogging() {
+ org.apache.logging.log4j.Logger logger =
LogManager.getLogger("org.apache.logging.log4j.test1");
+ logger.log(ExtendedLevels.DETAIL, "Detail message");
+ logger.log(Level.DEBUG, "Debug message");
+ List<LogEvent> events = list1.getEvents();
+ assertNotNull("No events", events);
+ assertTrue("Incorrect number of events. Expected 1 got " +
events.size(), events.size() == 1);
+ LogEvent event = events.get(0);
+ assertTrue("Expected level DETAIL, got" + event.getLevel(),
event.getLevel().name().equals("DETAIL"));
+ logger = LogManager.getLogger("org.apache.logging.log4j.test2");
+ logger.log(ExtendedLevels.NOTE, "Note message");
+ logger.log(Level.INFO, "Info message");
+ events = list2.getEvents();
+ assertNotNull("No events", events);
+ assertTrue("Incorrect number of events. Expected 1 got " +
events.size(), events.size() == 1);
+ event = events.get(0);
+ assertTrue("Expected level NOTE, got" + event.getLevel(),
event.getLevel().name().equals("NOTE"));
+ }
+}
Modified:
logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/db/jpa/TestBaseEntity.java
URL:
http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/db/jpa/TestBaseEntity.java?rev=1561537&r1=1561536&r2=1561537&view=diff
==============================================================================
---
logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/db/jpa/TestBaseEntity.java
(original)
+++
logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/db/jpa/TestBaseEntity.java
Sun Jan 26 19:34:49 2014
@@ -36,6 +36,7 @@ import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.Marker;
import org.apache.logging.log4j.ThreadContext;
import org.apache.logging.log4j.core.LogEvent;
+import
org.apache.logging.log4j.core.appender.db.jpa.converter.LevelAttributeConverter;
import
org.apache.logging.log4j.core.appender.db.jpa.converter.MessageAttributeConverter;
import
org.apache.logging.log4j.core.appender.db.jpa.converter.ThrowableAttributeConverter;
import org.apache.logging.log4j.message.Message;
@@ -78,7 +79,7 @@ public class TestBaseEntity extends Abst
}
@Override
- @Enumerated(EnumType.STRING)
+ @Convert(converter = LevelAttributeConverter.class)
@Column(name = "level")
public Level getLevel() {
return this.getWrappedEvent().getLevel();
Added:
logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/test/ExtendedLevels.java
URL:
http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/test/ExtendedLevels.java?rev=1561537&view=auto
==============================================================================
---
logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/test/ExtendedLevels.java
(added)
+++
logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/test/ExtendedLevels.java
Sun Jan 26 19:34:49 2014
@@ -0,0 +1,30 @@
+/*
+ * 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.test;
+
+import org.apache.logging.log4j.Level;
+import org.apache.logging.log4j.core.config.plugins.Plugin;
+
+/**
+ *
+ */
+@Plugin(name="ExtendedLevel", category="Level")
+public class ExtendedLevels {
+
+ public static final Level NOTE = new Level("NOTE", 350){};
+ public static final Level DETAIL = new Level("DETAIL", 450){};
+}
Modified:
logging/log4j/log4j2/trunk/log4j-core/src/test/resources/META-INF/persistence.xml
URL:
http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/test/resources/META-INF/persistence.xml?rev=1561537&r1=1561536&r2=1561537&view=diff
==============================================================================
---
logging/log4j/log4j2/trunk/log4j-core/src/test/resources/META-INF/persistence.xml
(original)
+++
logging/log4j/log4j2/trunk/log4j-core/src/test/resources/META-INF/persistence.xml
Sun Jan 26 19:34:49 2014
@@ -28,6 +28,7 @@
<class>org.apache.logging.log4j.core.appender.db.jpa.converter.ContextMapJsonAttributeConverter</class>
<class>org.apache.logging.log4j.core.appender.db.jpa.converter.ContextStackAttributeConverter</class>
<class>org.apache.logging.log4j.core.appender.db.jpa.converter.ContextStackJsonAttributeConverter</class>
+
<class>org.apache.logging.log4j.core.appender.db.jpa.converter.LevelAttributeConverter</class>
<class>org.apache.logging.log4j.core.appender.db.jpa.converter.MarkerAttributeConverter</class>
<class>org.apache.logging.log4j.core.appender.db.jpa.converter.MessageAttributeConverter</class>
<class>org.apache.logging.log4j.core.appender.db.jpa.converter.StackTraceElementAttributeConverter</class>
@@ -51,6 +52,7 @@
<class>org.apache.logging.log4j.core.appender.db.jpa.converter.ContextMapJsonAttributeConverter</class>
<class>org.apache.logging.log4j.core.appender.db.jpa.converter.ContextStackAttributeConverter</class>
<class>org.apache.logging.log4j.core.appender.db.jpa.converter.ContextStackJsonAttributeConverter</class>
+
<class>org.apache.logging.log4j.core.appender.db.jpa.converter.LevelAttributeConverter</class>
<class>org.apache.logging.log4j.core.appender.db.jpa.converter.MarkerAttributeConverter</class>
<class>org.apache.logging.log4j.core.appender.db.jpa.converter.MessageAttributeConverter</class>
<class>org.apache.logging.log4j.core.appender.db.jpa.converter.StackTraceElementAttributeConverter</class>
Copied:
logging/log4j/log4j2/trunk/log4j-core/src/test/resources/log4j-customLevel.xml
(from r1561366,
logging/log4j/log4j2/trunk/log4j-core/src/test/resources/log4j-test1.xml)
URL:
http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/test/resources/log4j-customLevel.xml?p2=logging/log4j/log4j2/trunk/log4j-core/src/test/resources/log4j-customLevel.xml&p1=logging/log4j/log4j2/trunk/log4j-core/src/test/resources/log4j-test1.xml&r1=1561366&r2=1561537&rev=1561537&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-core/src/test/resources/log4j-test1.xml
(original)
+++
logging/log4j/log4j2/trunk/log4j-core/src/test/resources/log4j-customLevel.xml
Sun Jan 26 19:34:49 2014
@@ -17,37 +17,27 @@
-->
<Configuration status="warn" name="XMLConfigTest"
packages="org.apache.logging.log4j.test">
- <Properties>
- <Property name="filename">target/test.log</Property>
- </Properties>
- <ThresholdFilter level="debug"/>
<Appenders>
<Console name="STDOUT">
<PatternLayout pattern="%m%n"/>
</Console>
- <File name="File" fileName="${filename}" bufferedIO="false">
- <PatternLayout>
- <Pattern>%d %p %C{1.} [%t] %m%n</Pattern>
- </PatternLayout>
- </File>
- <List name="List">
+ <List name="List1">
+ </List>
+ <List name="List2">
<Filters>
- <ThresholdFilter level="error"/>
+ <ThresholdFilter level="note"/>
</Filters>
</List>
</Appenders>
<Loggers>
- <Logger name="org.apache.logging.log4j.test1" level="debug"
additivity="false">
- <ThreadContextMapFilter>
- <KeyValuePair key="test" value="123"/>
- </ThreadContextMapFilter>
- <AppenderRef ref="STDOUT"/>
+ <Logger name="org.apache.logging.log4j.test1" level="detail"
additivity="false">
+ <AppenderRef ref="List1"/>
</Logger>>
- <Logger name="org.apache.logging.log4j.test2" level="debug"
additivity="false">
- <AppenderRef ref="File"/>
+ <Logger name="org.apache.logging.log4j.test2" level="info"
additivity="false">
+ <AppenderRef ref="List2"/>
</Logger>>
<Root level="error">
Modified:
logging/log4j/log4j2/trunk/log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/SLF4JLogger.java
URL:
http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/SLF4JLogger.java?rev=1561537&r1=1561536&r2=1561537&view=diff
==============================================================================
---
logging/log4j/log4j2/trunk/log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/SLF4JLogger.java
(original)
+++
logging/log4j/log4j2/trunk/log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/SLF4JLogger.java
Sun Jan 26 19:34:49 2014
@@ -18,6 +18,7 @@ package org.apache.logging.slf4j;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.Marker;
+import org.apache.logging.log4j.Level.StdLevel;
import org.apache.logging.log4j.message.LoggerNameAwareMessage;
import org.apache.logging.log4j.message.Message;
import org.apache.logging.log4j.message.MessageFactory;
@@ -56,7 +57,7 @@ public class SLF4JLogger extends Abstrac
locationAwareLogger.log(getMarker(marker), fqcn,
convertLevel(level), data.getFormattedMessage(),
data.getParameters(), t);
} else {
- switch (level) {
+ switch (StdLevel.getStdLevel(level)) {
case DEBUG :
logger.debug(getMarker(marker),
data.getFormattedMessage(), data.getParameters(), t);
break;
@@ -93,7 +94,7 @@ public class SLF4JLogger extends Abstrac
}
private int convertLevel(final Level level) {
- switch (level) {
+ switch (StdLevel.getStdLevel(level)) {
case DEBUG :
return LocationAwareLogger.DEBUG_INT;
case TRACE :
@@ -136,7 +137,7 @@ public class SLF4JLogger extends Abstrac
private boolean isEnabledFor(final Level level, final Marker marker) {
final org.slf4j.Marker slf4jMarker = getMarker(marker);
- switch (level) {
+ switch (StdLevel.getStdLevel(level)) {
case DEBUG :
return logger.isDebugEnabled(slf4jMarker);
case TRACE :
Modified: logging/log4j/log4j2/trunk/src/changes/changes.xml
URL:
http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/src/changes/changes.xml?rev=1561537&r1=1561536&r2=1561537&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/src/changes/changes.xml (original)
+++ logging/log4j/log4j2/trunk/src/changes/changes.xml Sun Jan 26 19:34:49 2014
@@ -20,7 +20,10 @@
<title>Changes</title>
</properties>
<body>
- <release version="2.0-RC1" date="2014-MM-DD" description="Bug fixes and
enhancements">
+ <release version="2.0-RC1" date="2014-MM-DD" description="Bug fixes and
enhancements">
+ <action issue="LOG4J2-41" dev="rgoers" type="update" due-to="Nick
Williams">
+ Add support for custom logging levels.
+ </action>
<action issue="LOG4J2-507" dev="ggregory" type="update">
Space Level numbers by 100 instead of 1.
</action>