public final class BukkitPluginLoggerAdapter
extends org.slf4j.helpers.MarkerIgnoringBase
A merger of SLF4J's SimpleLogger and JDK14LoggerAdapter,
wired to log all messages to the enclosing Bukkit plugin. The plugin is
identified by reading the "name" attribute from plugin.yml in the
current classloader.
Plugins that include SLF4Bukkit can use the following values in
config.yml to configure the behavior of SLF4Bukkit. SLF4Bukkit uses
Bukkit's plugin configuration API to retrieve config values, so both on-disk
and built-in config.yml behavior is supported.
slf4j.defaultLogLevel - Default log level for all SLF4Bukkit
loggers in this plugin. Must be one of "trace", "debug", "info", "warn", or
"error". Defaults to "info".slf4j.log.a.b.c - Logging detail level for an
SLF4Bukkit logger instance in this plugin named "a.b.c". Right-side value
must be one of "trace", "debug", "info", "warn", or "error". When a logger
named "a.b.c" is initialized, its level is assigned from this property. If
unspecified, the level of the nearest parent logger will be used. If no
parent logger level is set, then the value specified by
slf4j.defaultLogLevel for this plugin will be used.slf4j.showHeader -Set to true if you want to
output the [SLF4J] header. Defaults to false.slf4j.showThreadName -Set to true if you want
to output the current thread name. Defaults to false.slf4j.showLogName - Set to true if you want the
logger instance name to be included in output messages. Defaults to
false.slf4j.showShortLogName - Set to true if you
want the logger instance's short name to be included in output messages. The
short name is equal to the full name with every dot-separated portion of the
full name (except the last portion) truncated to its first character.
Defaults to true.
SLF4J messages at level TRACE or DEBUG are logged to Bukkit
at level INFO because Bukkit does not enable any levels higher than
INFO. Therefore, only SLF4J messages at level TRACE or
DEBUG show their SLF4J level in the message that is logged to the
server console.
Because SLF4Bukkit's configuration comes from the plugin configuration,
SLF4Bukkit supports configuration reloading. To achieve this, call
init(boolean) with argument true after calling
Plugin.reloadConfig().
It is possible for SLF4J loggers to be used before the plugin is registered with Bukkit's plugin manager. SLF4Bukkit is considered to be uninitialized as long as the plugin cannot be retrieved from Bukkit's plugin manager. While in the uninitialized state, SLF4Bukkit:
Bukkit.getLogger() instead of Plugin.getLogger().Plugin.getLogger() and the plugin YAML
configuration values are used.
For this reason, it is strongly recommended that you not emit any log
messages via SLF4Bukkit until your plugin's onLoad()
method has begun execution. (You can safely log messages inside the
onLoad() method, because your plugin is registered by that time.)
Logging inside static initializers, the plugin class constructor and other
pre-plugin-registration areas of your code is discouraged.
With no configuration, the default output includes the logger short name and the message, followed by the line separator for the host.
| Modifier and Type | Method and Description |
|---|---|
void |
debug(String msg)
A simple implementation which logs messages of level DEBUG according
to the format outlined above.
|
void |
debug(String format,
Object... argArray)
Perform double parameter substitution before logging the message of level
DEBUG according to the format outlined above.
|
void |
debug(String format,
Object param1)
Perform single parameter substitution before logging the message of level
DEBUG according to the format outlined above.
|
void |
debug(String format,
Object param1,
Object param2)
Perform double parameter substitution before logging the message of level
DEBUG according to the format outlined above.
|
void |
debug(String msg,
Throwable t)
Log a message of level DEBUG, including an exception.
|
void |
error(String msg)
A simple implementation which always logs messages of level ERROR according
to the format outlined above.
|
void |
error(String format,
Object... argArray)
Perform double parameter substitution before logging the message of level
ERROR according to the format outlined above.
|
void |
error(String format,
Object arg)
Perform single parameter substitution before logging the message of level
ERROR according to the format outlined above.
|
void |
error(String format,
Object arg1,
Object arg2)
Perform double parameter substitution before logging the message of level
ERROR according to the format outlined above.
|
void |
error(String msg,
Throwable t)
Log a message of level ERROR, including an exception.
|
void |
info(String msg)
A simple implementation which logs messages of level INFO according
to the format outlined above.
|
void |
info(String format,
Object... argArray)
Perform double parameter substitution before logging the message of level
INFO according to the format outlined above.
|
void |
info(String format,
Object arg)
Perform single parameter substitution before logging the message of level
INFO according to the format outlined above.
|
void |
info(String format,
Object arg1,
Object arg2)
Perform double parameter substitution before logging the message of level
INFO according to the format outlined above.
|
void |
info(String msg,
Throwable t)
Log a message of level INFO, including an exception.
|
static void |
init(boolean reinitialize)
(Re)initializes all SLF4Bukkit loggers, relying on the YAML configuration
of the enclosing plugin.
|
boolean |
isDebugEnabled()
Are
debug messages currently enabled? |
boolean |
isErrorEnabled()
Are
error messages currently enabled? |
boolean |
isInfoEnabled()
Are
info messages currently enabled? |
boolean |
isTraceEnabled()
Are
trace messages currently enabled? |
boolean |
isWarnEnabled()
Are
warn messages currently enabled? |
protected Object |
readResolve() |
void |
trace(String msg)
A simple implementation which logs messages of level TRACE according
to the format outlined above.
|
void |
trace(String format,
Object... argArray)
Perform double parameter substitution before logging the message of level
TRACE according to the format outlined above.
|
void |
trace(String format,
Object param1)
Perform single parameter substitution before logging the message of level
TRACE according to the format outlined above.
|
void |
trace(String format,
Object param1,
Object param2)
Perform double parameter substitution before logging the message of level
TRACE according to the format outlined above.
|
void |
trace(String msg,
Throwable t)
Log a message of level TRACE, including an exception.
|
void |
warn(String msg)
A simple implementation which always logs messages of level WARN according
to the format outlined above.
|
void |
warn(String format,
Object... argArray)
Perform double parameter substitution before logging the message of level
WARN according to the format outlined above.
|
void |
warn(String format,
Object arg)
Perform single parameter substitution before logging the message of level
WARN according to the format outlined above.
|
void |
warn(String format,
Object arg1,
Object arg2)
Perform double parameter substitution before logging the message of level
WARN according to the format outlined above.
|
void |
warn(String msg,
Throwable t)
Log a message of level WARN, including an exception.
|
debug, debug, debug, debug, debug, error, error, error, error, error, info, info, info, info, info, isDebugEnabled, isErrorEnabled, isInfoEnabled, isTraceEnabled, isWarnEnabled, toString, trace, trace, trace, trace, trace, warn, warn, warn, warn, warnprotected String name
public static void init(boolean reinitialize)
reinitialize - set to true to reinitialize all loggers, e.g. after
reloading the plugin config.public void debug(String msg)
public void debug(String format, Object param1)
public void debug(String format, Object... argArray)
public void debug(String format, Object param1, Object param2)
public void debug(String msg, Throwable t)
public void error(String msg)
public void error(String format, Object arg)
public void error(String format, Object... argArray)
public void error(String format, Object arg1, Object arg2)
public void error(String msg, Throwable t)
public void info(String msg)
public void info(String format, Object arg)
public void info(String format, Object... argArray)
public void info(String format, Object arg1, Object arg2)
public boolean isDebugEnabled()
debug messages currently enabled?public boolean isErrorEnabled()
error messages currently enabled?public boolean isInfoEnabled()
info messages currently enabled?public boolean isTraceEnabled()
trace messages currently enabled?public boolean isWarnEnabled()
warn messages currently enabled?public void trace(String msg)
public void trace(String format, Object param1)
public void trace(String format, Object... argArray)
public void trace(String format, Object param1, Object param2)
public void trace(String msg, Throwable t)
public void warn(String msg)
public void warn(String format, Object arg)
public void warn(String format, Object... argArray)
public void warn(String format, Object arg1, Object arg2)
protected Object readResolve() throws ObjectStreamException
ObjectStreamExceptionCopyright © 2016. All rights reserved.