Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.logging.log4j
Interface LevelLogger

    public interface LevelLogger

This is the central interface in the log4j package. Most logging operations, except configuration, are done through this interface.

The canonical way to obtain a Logger for a class is through `LogManager.getLogger()`. Typically, each class gets its own Logger named after its fully qualified class name (the default Logger name when obtained through the `LogManager.getLogger()` method). Thus, the simplest way to use this would be like so:

     public class MyClass {
         private static final Logger LOGGER = LogManager.getLogger();
         // ...
     }

For ease of filtering, searching, sorting, etc., it is generally a good idea to create Loggers for each class rather than sharing Loggers. Instead, `Markers` should be used for shared, filterable identification.

For service provider implementations, it is recommended to extend the `AbstractLogger` class rather than implementing this interface directly.

Method Summary
`void` | `catching(Throwable t)` Logs an exception or error that has been caught.
`void` | `entry()` Logs entry to a method.
`void` | `entry(Object... params)` Logs entry to a method along with its parameters.
`void` | `exit()` Logs exit from a method.
`
`<R> R`
` | `exit(R result)` Logs exiting from a method with the result.
`Level` | `getLevel()` Gets the Level associated with the Logger.
`MessageFactory` | `getMessageFactory()` Gets the message factory used to convert message Objects and Strings into actual log Messages.
`String` | `getName()` Gets the logger name.
`boolean` | `isDebugEnabled()` Checks whether this Logger is enabled for the `DEBUG` Level.
`boolean` | `isDebugEnabled(Marker marker)` Checks whether this Logger is enabled for the `DEBUG` Level.
`boolean` | `isEnabled(Level level)` Checks whether this Logger is enabled for the the given Level.
`boolean` | `isEnabled(Marker marker)` Checks whether this logger is enabled at the specified level and an optional Marker.
`boolean` | `isErrorEnabled()` Checks whether this Logger is enabled for the `ERROR` Level.
`boolean` | `isErrorEnabled(Marker marker)` Checks whether this Logger is enabled for the `ERROR` Level.
`boolean` | `isFatalEnabled()` Checks whether this Logger is enabled for the `FATAL` Level.
`boolean` | `isFatalEnabled(Marker marker)` Checks whether this Logger is enabled for the `FATAL` Level.
`boolean` | `isInfoEnabled()` Checks whether this Logger is enabled for the `INFO` Level.
`boolean` | `isInfoEnabled(Marker marker)` Checks whether this Logger is enabled for the `INFO` Level.
`boolean` | `isTraceEnabled()` Checks whether this Logger is enabled for the `TRACE` level.
`boolean` | `isTraceEnabled(Marker marker)` Checks whether this Logger is enabled for the `TRACE` level.
`boolean` | `isWarnEnabled()` Checks whether this Logger is enabled for the `WARN` Level.
`boolean` | `isWarnEnabled(Marker marker)` Checks whether this Logger is enabled for the `WARN` Level.
`void` | `log(Marker marker, Message msg)` Logs a message with the specific Marker at the given level.
`void` | `log(Marker marker, Message msg, Throwable t)` Logs a message with the specific Marker at the given level.
`void` | `log(Marker marker, Object message)` Logs a message object with the given level.
`void` | `log(Marker marker, Object message, Throwable t)` Logs a message at the given level including the stack trace of the `Throwable` `t` passed as parameter.
`void` | `log(Marker marker, String message)` Logs a message object with the given level.
`void` | `log(Marker marker, String message, Object... params)` Logs a message with parameters at the given level.
`void` | `log(Marker marker, String message, Throwable t)` Logs a message at the given level including the stack trace of the `Throwable` `t` passed as parameter.
`void` | `log(Message msg)` Logs a message with the specific Marker at the given level.
`void` | `log(Message msg, Throwable t)` Logs a message with the specific Marker at the given level.
`void` | `log(Object message)` Logs a message object with the given level.
`void` | `log(Object message, Throwable t)` Logs a message at the given level including the stack trace of the `Throwable` `t` passed as parameter.
`void` | `log(String message)` Logs a message object with the given level.
`void` | `log(String message, Object... params)` Logs a message with parameters at the given level.
`void` | `log(String message, Throwable t)` Logs a message at the given level including the stack trace of the `Throwable` `t` passed as parameter.
`void` | `printf(Marker marker, String format, Object... params)` Logs a formatted message using the specified format string and arguments.
`void` | `printf(String format, Object... params)` Logs a formatted message using the specified format string and arguments.
`
`<T extends Throwable> T`
` | `throwing(T t)` Logs an exception or error to be thrown.

Method Detail

### catching

    void catching(Throwable t)

  Logs an exception or error that has been caught. Normally, one may wish to provide additional information with an exception while logging it; in these cases, one would not use this method. In other cases where simply logging the fact that an exception was swallowed somewhere (e.g., at the top of the stack trace in a `main()` method), this method is ideal for it.

  Parameters:
    `t` - The Throwable.

### entry

    void entry()

  Logs entry to a method. Used when the method in question has no parameters or when the parameters should not be logged.

### entry

    void entry(Object... params)

  Logs entry to a method along with its parameters. For example,

       public void doSomething(String foo, int bar) {
           LOGGER.entry(foo, bar);
           // do something
       }

  The use of methods such as this are more effective when combined with aspect-oriented programming or other bytecode manipulation tools. It can be rather tedious (and messy) to use this type of method manually.

  Parameters:
    `params` - The parameters to the method. TODO Use of varargs results in array creation which can be a substantial portion of no-op case. LogMF/LogSF provides several overrides to avoid vararg except in edge cases. (RG) LogMF and LogSF implement these in LogXF which calls logger.callAppenders. callAppenders is part of the implementation and cannot be used by the API. Adding more methods here and in AbstractLogger is sufficient.

### exit

    void exit()

  Logs exit from a method. Used for methods that do not return anything.

### exit

    <R> R exit(R result)

  Logs exiting from a method with the result. This may be coded as:

       return LOGGER.exit(myResult);

  Type Parameters:
    `R` - The type of the parameter and object being returned.
  Parameters:
    `result` - The result being returned from the method call.
  Returns:
    the result.

### getLevel

    Level getLevel()

  Gets the Level associated with the Logger.

  Returns:
    the Level associate with the Logger.

### getMessageFactory

    MessageFactory getMessageFactory()

  Gets the message factory used to convert message Objects and Strings into actual log Messages.

  Returns:
    the message factory.

### getName

    String getName()

  Gets the logger name.

  Returns:
    the logger name.

### isDebugEnabled

    boolean isDebugEnabled()

  Checks whether this Logger is enabled for the `DEBUG` Level.

  Returns:
    boolean - `true` if this Logger is enabled for level DEBUG, `false` otherwise.

### isDebugEnabled

    boolean isDebugEnabled(Marker marker)

  Checks whether this Logger is enabled for the `DEBUG` Level.

  Parameters:
    `marker` - The marker data specific to this log statement.
  Returns:
    boolean - `true` if this Logger is enabled for level DEBUG, `false` otherwise.

### isEnabled

    boolean isEnabled(Level level)

  Checks whether this Logger is enabled for the the given Level.

  Note that passing in `OFF` always returns `true`.

  Returns:
    boolean - `true` if this Logger is enabled for level, `false` otherwise.

### isEnabled

    boolean isEnabled(Marker marker)

  Checks whether this logger is enabled at the specified level and an optional Marker.

  Parameters:
    `marker` - The marker data specific to this log statement.
  Returns:
    boolean - `true` if this Logger is enabled for level `WARN`, `false` otherwise.

### isErrorEnabled

    boolean isErrorEnabled()

  Checks whether this Logger is enabled for the `ERROR` Level.

  Returns:
    boolean - `true` if this Logger is enabled for level `ERROR`, `false` otherwise.

### isErrorEnabled

    boolean isErrorEnabled(Marker marker)

  Checks whether this Logger is enabled for the `ERROR` Level.

  Parameters:
    `marker` - The marker data specific to this log statement.
  Returns:
    boolean - `true` if this Logger is enabled for level `ERROR`, `false` otherwise.

### isFatalEnabled

    boolean isFatalEnabled()

  Checks whether this Logger is enabled for the `FATAL` Level.

  Returns:
    boolean - `true` if this Logger is enabled for level `FATAL`, `false` otherwise.

### isFatalEnabled

    boolean isFatalEnabled(Marker marker)

  Checks whether this Logger is enabled for the `FATAL` Level.

  Parameters:
    `marker` - The marker data specific to this log statement.
  Returns:
    boolean - `true` if this Logger is enabled for level `FATAL`, `false` otherwise.

### isInfoEnabled

    boolean isInfoEnabled()

  Checks whether this Logger is enabled for the `INFO` Level.

  Returns:
    boolean - `true` if this Logger is enabled for level INFO, `false` otherwise.

### isInfoEnabled

    boolean isInfoEnabled(Marker marker)

  Checks whether this Logger is enabled for the `INFO` Level.

  Parameters:
    `marker` - The marker data specific to this log statement.
  Returns:
    boolean - `true` if this Logger is enabled for level INFO, `false` otherwise.

### isTraceEnabled

    boolean isTraceEnabled()

  Checks whether this Logger is enabled for the `TRACE` level.

  Returns:
    boolean - `true` if this Logger is enabled for level TRACE, `false` otherwise.

### isTraceEnabled

    boolean isTraceEnabled(Marker marker)

  Checks whether this Logger is enabled for the `TRACE` level.

  Parameters:
    `marker` - The marker data specific to this log statement.
  Returns:
    boolean - `true` if this Logger is enabled for level TRACE, `false` otherwise.

### isWarnEnabled

    boolean isWarnEnabled()

  Checks whether this Logger is enabled for the `WARN` Level.

  Returns:
    boolean - `true` if this Logger is enabled for level `WARN`, `false` otherwise.

### isWarnEnabled

    boolean isWarnEnabled(Marker marker)

  Checks whether this Logger is enabled for the `WARN` Level.

  Parameters:
    `marker` - The marker data specific to this log statement.
  Returns:
    boolean - `true` if this Logger is enabled for level `WARN`, `false` otherwise.

### log

    void log(Marker marker,
             Message msg)

  Logs a message with the specific Marker at the given level.

  Parameters:
    `marker` - the marker data specific to this log statement
    `msg` - the message string to be logged

### log

    void log(Marker marker,
             Message msg,
             Throwable t)

  Logs a message with the specific Marker at the given level.

  Parameters:
    `marker` - the marker data specific to this log statement
    `msg` - the message string to be logged
    `t` - A Throwable or null.

### log

    void log(Marker marker,
             Object message)

  Logs a message object with the given level.

  Parameters:
    `marker` - the marker data specific to this log statement
    `message` - the message object to log.

### log

    void log(Marker marker,
             Object message,
             Throwable t)

  Logs a message at the given level including the stack trace of the `Throwable` `t` passed as parameter.

  Parameters:
    `marker` - the marker data specific to this log statement
    `message` - the message to log.
    `t` - the exception to log, including its stack trace.

### log

    void log(Marker marker,
             String message)

  Logs a message object with the given level.

  Parameters:
    `marker` - the marker data specific to this log statement
    `message` - the message object to log.

### log

    void log(Marker marker,
             String message,
             Object... params)

  Logs a message with parameters at the given level.

  Parameters:
    `marker` - the marker data specific to this log statement
    `message` - the message to log; the format depends on the message factory.
    `params` - parameters to the message.
  See Also:
    `getMessageFactory()`

### log

    void log(Marker marker,
             String message,
             Throwable t)

  Logs a message at the given level including the stack trace of the `Throwable` `t` passed as parameter.

  Parameters:
    `marker` - the marker data specific to this log statement
    `message` - the message to log.
    `t` - the exception to log, including its stack trace.

### log

    void log(Message msg)

  Logs a message with the specific Marker at the given level.

  Parameters:
    `msg` - the message string to be logged

### log

    void log(Message msg,
             Throwable t)

  Logs a message with the specific Marker at the given level.

  Parameters:
    `msg` - the message string to be logged
    `t` - A Throwable or null.

### log

    void log(Object message)

  Logs a message object with the given level.

  Parameters:
    `message` - the message object to log.

### log

    void log(Object message,
             Throwable t)

  Logs a message at the given level including the stack trace of the `Throwable` `t` passed as parameter.

  Parameters:
    `message` - the message to log.
    `t` - the exception to log, including its stack trace.

### log

    void log(String message)

  Logs a message object with the given level.

  Parameters:
    `message` - the message string to log.

### log

    void log(String message,
             Object... params)

  Logs a message with parameters at the given level.

  Parameters:
    `message` - the message to log; the format depends on the message factory.
    `params` - parameters to the message.
  See Also:
    `getMessageFactory()`

### log

    void log(String message,
             Throwable t)

  Logs a message at the given level including the stack trace of the `Throwable` `t` passed as parameter.

  Parameters:
    `message` - the message to log.
    `t` - the exception to log, including its stack trace.

### printf

    void printf(Marker marker,
                String format,
                Object... params)

  Logs a formatted message using the specified format string and arguments.

  Parameters:
    `marker` - the marker data specific to this log statement.
    `format` - The format String.
    `params` - Arguments specified by the format.

### printf

    void printf(String format,
                Object... params)

  Logs a formatted message using the specified format string and arguments.

  Parameters:
    `format` - The format String.
    `params` - Arguments specified by the format.

### throwing

    <T extends Throwable> T throwing(T t)

  Logs an exception or error to be thrown. This may be coded as:

       throw logger.throwing(myException);

  Type Parameters:
    `T` - the Throwable type.
  Parameters:
    `t` - The Throwable.
  Returns:
    the Throwable.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 1999-2015 Apache Software Foundation. All Rights Reserved.
Apache Logging, Apache Log4j, Log4j, Apache, the Apache feather logo, the Apache Logging project logo, and the Apache Log4j logo are trademarks of The Apache Software Foundation.