api 1.7 y slf4j-simple como implementación. Simplemente no puedo encontrar cómo configurar el nivel de registro con esta combinación.
¿Alguien puede ayudarme?
Ya sea a través de la propiedad del sistema
-Dorg.slf4j.simpleLogger.defaultLogLevel=debug
o el archivo simplelogger.properties
en el classpath
consulte http://www.slf4j.org/api/org/slf4j/impl/SimpleLogger.html para más detalles
Este es un ejemplo de simplelogger.properties
que puede colocar en el classpath (descomente las propiedades que desee utilizar):
idioma: ninguno -->
# SLF4J's SimpleLogger configuration file
# Simple implementation of Logger that sends all enabled log messages, for all defined loggers, to System.err.
# Default logging detail level for all instances of SimpleLogger.
# Must be one of ("trace", "debug", "info", "warn", or "error").
# If not specified, defaults to "info".
#org.slf4j.simpleLogger.defaultLogLevel=info
# Logging detail level for a SimpleLogger instance named "xxxxx".
# Must be one of ("trace", "debug", "info", "warn", or "error").
# If not specified, the default logging detail level is used.
#org.slf4j.simpleLogger.log.xxxxx=
# Set to true if you want the current date and time to be included in output messages.
# Default is false, and will output the number of milliseconds elapsed since startup.
#org.slf4j.simpleLogger.showDateTime=false
# The date and time format to be used in the output messages.
# The pattern describing the date and time format is the same that is used in java.text.SimpleDateFormat.
# If the format is not specified or is invalid, the default format is used.
# The default format is yyyy-MM-dd HH:mm:ss:SSS Z.
#org.slf4j.simpleLogger.dateTimeFormat=yyyy-MM-dd HH:mm:ss:SSS Z
# Set to true if you want to output the current thread name.
# Defaults to true.
#org.slf4j.simpleLogger.showThreadName=true
# Set to true if you want the Logger instance name to be included in output messages.
# Defaults to true.
#org.slf4j.simpleLogger.showLogName=true
# Set to true if you want the last component of the name to be included in output messages.
# Defaults to false.
#org.slf4j.simpleLogger.showShortLogName=false
Puede cambiarla mediante programación estableciendo la propiedad del sistema:
public class App {
public static void main(String[] args) {
System.setProperty(org.slf4j.impl.SimpleLogger.DEFAULT_LOG_LEVEL_KEY, "TRACE");
final org.slf4j.Logger log = LoggerFactory.getLogger(App.class);
log.trace("trace");
log.debug("debug");
log.info("info");
log.warn("warning");
log.error("error");
}
}
Los niveles de registro son ERROR > WARN > INFO > DEBUG > TRACE.
Tenga en cuenta que una vez creado el registrador, el nivel de registro no se puede cambiar. Si necesita cambiar dinámicamente el nivel de registro puede utilizar log4j con SLF4J.