public class ClientLogger extends Object
Logger.
This logger logs formattable messages that use {} as the placeholder. When a throwable is the last
argument of the format varargs and the logger is enabled for verbose logging the
stack trace for the throwable will be included in the log message.
A minimum logging level threshold is determined by the AZURE_LOG_LEVEL
environment configuration, by default logging is disabled.
Log level hierarchy
Configuration| Constructor and Description |
|---|
ClientLogger(Class<?> clazz)
Retrieves a logger for the passed class using the
LoggerFactory. |
ClientLogger(String className)
Retrieves a logger for the passed class name using the
LoggerFactory. |
| Modifier and Type | Method and Description |
|---|---|
void |
error(String format,
Object... args)
Logs a formattable message that uses
{} as the placeholder at error log level |
void |
info(String format,
Object... args)
Logs a formattable message that uses
{} as the placeholder at informational log level |
void |
logAndThrow(RuntimeException runtimeException)
This will log
RuntimeException, if logging is enabled , and throw the runtime exception. |
void |
verbose(String format,
Object... args)
Logs a formattable message that uses
{} as the placeholder at verbose log level |
void |
warning(String format,
Object... args)
Logs a formattable message that uses
{} as the placeholder at warning log level |
public ClientLogger(Class<?> clazz)
LoggerFactory.clazz - Class creating the logger.public ClientLogger(String className)
LoggerFactory.className - Class name creating the logger.public void verbose(String format, Object... args)
{} as the placeholder at verbose log level
Code Samples
Logging a message at verbose log level
logger.verbose("A formattable message. Hello, {}", name);
format - The formattable message to logargs - Arguments for the message, if an exception is being logged last argument is the throwable.public void info(String format, Object... args)
{} as the placeholder at informational log level
Code Samples
Logging a message at informational log level
logger.info("A formattable message. Hello, {}", name);
format - The formattable message to logargs - Arguments for the message, if an exception is being logged last argument is the throwable.public void warning(String format, Object... args)
{} as the placeholder at warning log level
Code Samples
Logging a message at warning log level
logger.warning("A formattable message. Hello, {}", name);
format - The formattable message to logargs - Arguments for the message, if an exception is being logged last argument is the throwable.public void error(String format, Object... args)
{} as the placeholder at error log level
Code Samples
Logging an error with stack trace
try {
upload(resource);
} catch (IOException ex) {
logger.error("A formattable message. Hello, {}", name, ex);
}
format - The formattable message to logargs - Arguments for the message, if an exception is being logged last argument is the throwable.public void logAndThrow(RuntimeException runtimeException)
RuntimeException, if logging is enabled , and throw the runtime exception.runtimeException - to be thrown. It will do nothing if null is provided.RuntimeException - which is requested by this call.Copyright © 2019 Microsoft Corporation. All rights reserved.