CLoggerFactory
The logger factory generates loggers that can be used to output LOG. All methods of the class are static.
Creating a logger
A logger can be created by specifying a text ID. This text is used to identify the logger. In the log configuration you can assign a LOG level to this logger and thus determine if and when logging takes place.
@NotNull public static ILogger getLogger(@NotNull final Class<?> aClass);
The second variant takes a class. Internally the full class name including package is used as text ID.
@NotNull public static ILogger getLogger(@NotNull final String aName);
Usage
Loggers are often created as static members of a class and used in many methods.
Example:
private static final ILogger LOG = CLoggerFactory.getLogger(CMyClass.class); public void process(final String aId) { LOG.debug("I will now process {}.", aId); }
Fetch the LOG configuration
This method fetches the LOG configuration. Formatter and writer can be created by this configuration. In addition, LOG levels are assigned here to the individual loggers as well as to the writers.
@NotNull public static ILogConfiguration getConfiguration();