org.apache.ignite.logger.log4j

## Class Log4JLogger

- java.lang.Object
- - org.apache.ignite.logger.log4j.Log4JLogger

- All Implemented Interfaces:
    IgniteLogger, LoggerNodeIdAndApplicationAware, LoggerNodeIdAware

  Deprecated.
  Log4j 1.x had reached end of life and contains critical vulnerabilities. See the announcement. Please, be aware this module will be removed in the next releases. Use ignite-log4j2 module instead.

      @Deprecated
      public class Log4JLogger
      extends Object
      implements IgniteLogger, LoggerNodeIdAndApplicationAware

  Log4j-based implementation for logging. This logger should be used by loaders that have prefer log4j-based logging.

  Here is a typical example of configuring log4j logger in Ignite configuration file:

            <property name="gridLogger">
                <bean class="org.apache.ignite.logger.log4j.Log4JLogger">
                    <constructor-arg type="java.lang.String" value="config/ignite-log4j.xml"/>
                </bean>
            </property>

  and from your code:

            IgniteConfiguration cfg = new IgniteConfiguration();
            ...
            URL xml = U.resolveIgniteUrl("config/custom-log4j.xml");
            IgniteLogger log = new Log4JLogger(xml);
            ...
            cfg.setGridLogger(log);

  Please take a look at Apache Log4j 1.2 for additional information.

  It's recommended to use Ignite logger injection instead of using/instantiating logger in your task/job code. See `LoggerResource` annotation about logger injection.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `DEPRECATED_MSG` Deprecated.

    - ### Fields inherited from interface org.apache.ignite.IgniteLogger

      `DEV_ONLY`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Log4JLogger()` Deprecated. Creates new logger and automatically detects if root logger already has appenders configured.
    `Log4JLogger(boolean init)` Deprecated. Creates new logger.
    `Log4JLogger(File cfgFile)` Deprecated. Creates new logger with given configuration `cfgFile`.
    `Log4JLogger(File cfgFile, long watchDelay)` Deprecated. Creates new logger with given configuration `cfgFile`.
    `Log4JLogger(org.apache.log4j.Logger impl)` Deprecated. Creates new logger with given implementation.
    `Log4JLogger(String path)` Deprecated. Creates new logger with given configuration `path`.
    `Log4JLogger(String path, long watchDelay)` Deprecated. Creates new logger with given configuration `path`.
    `Log4JLogger(URL cfgUrl)` Deprecated. Creates new logger with given configuration `cfgUrl`.
    `Log4JLogger(URL cfgUrl, long watchDelay)` Deprecated. Creates new logger with given configuration `cfgUrl`.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `static void` | `addAppender(org.apache.log4j.FileAppender a)` Deprecated. Adds file appender.
    `void` | `debug(String msg)` Deprecated. Logs out debug message.
    `void` | `error(String msg)` Deprecated. Logs out error message.
    `void` | `error(String msg, @Nullable Throwable e)` Deprecated. Logs error message with optional exception.
    `@Nullable String` | `fileName()` Deprecated. Gets name of the file being logged to if one is configured or `null` otherwise.
    `Log4JLogger` | `getLogger(Object ctgr)` Deprecated. Gets `IgniteLogger` wrapper around log4j logger for the given category.
    `UUID` | `getNodeId()` Deprecated. Gets node ID.
    `void` | `info(String msg)` Deprecated. Logs out information message.
    `static boolean` | `isConfigured()` Deprecated. Checks if Log4j is already configured within this VM or not.
    `boolean` | `isDebugEnabled()` Deprecated. Tests whether `debug` level is enabled.
    `boolean` | `isInfoEnabled()` Deprecated. Tests whether `info` level is enabled.
    `boolean` | `isQuiet()` Deprecated. Tests whether Logger is in "Quiet mode".
    `boolean` | `isTraceEnabled()` Deprecated. Tests whether `trace` level is enabled.
    `static Collection<String>` | `logFiles()` Deprecated. Gets files for all registered file appenders.
    `static void` | `removeAppender(org.apache.log4j.FileAppender a)` Deprecated. Removes file appender.
    `void` | `setApplicationAndNode(@Nullable String application, UUID nodeId)` Deprecated. Sets application name and node ID.
    `void` | `setLevel(org.apache.log4j.Level level)` Deprecated. Sets level for internal log4j implementation.
    `String` | `toString()` Deprecated.
    `void` | `trace(String msg)` Deprecated. Logs out trace message.
    `void` | `updateFilePath(IgniteClosure<String,String> filePathClos)` Deprecated. Sets closure that later evaluate file path.
    `void` | `warning(String msg)` Deprecated. Logs out warning message.
    `void` | `warning(String msg, @Nullable Throwable e)` Deprecated. Logs out warning message with optional exception.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface org.apache.ignite.IgniteLogger

      `debug, error, info, trace, warning`

    - ### Methods inherited from interface org.apache.ignite.logger.LoggerNodeIdAndApplicationAware

      `setNodeId`

- - ### Field Detail

    - #### DEPRECATED_MSG

          public static final String DEPRECATED_MSG

      Deprecated.
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### Log4JLogger

          public Log4JLogger()

      Deprecated.
      Creates new logger and automatically detects if root logger already has appenders configured. If it does not, the root logger will be configured with default appender (analogous to calling `Log4JLogger(boolean)` with parameter `true`, otherwise, existing appenders will be used (analogous to calling `Log4JLogger(boolean)` with parameter `false`).

    - #### Log4JLogger

          public Log4JLogger(boolean init)

      Deprecated.
      Creates new logger. If initialize parameter is `true` the Log4j logger will be initialized with default console appender and `INFO` log level.
      Parameters:
        `init` - If `true`, then a default console appender with following pattern layout will be created: `%d{ISO8601} %-5p [%c{1}] %m%n`. If `false`, then no implicit initialization will take place, and `Log4j` should be configured prior to calling this constructor.

    - #### Log4JLogger

          public Log4JLogger(org.apache.log4j.Logger impl)

      Deprecated.
      Creates new logger with given implementation.
      Parameters:
        `impl` - Log4j implementation to use.

    - #### Log4JLogger

          public Log4JLogger(String path)
                      throws IgniteCheckedException

      Deprecated.
      Creates new logger with given configuration `path`. Calling this constructor is equivalent to calling `Log4JLogger(path, FileWatchdog.DEFAULT_DELAY`.
      Parameters:
        `path` - Path to log4j configuration XML file.
      Throws:
        `IgniteCheckedException` - Thrown in case logger can't be created.

    - #### Log4JLogger

          public Log4JLogger(String path,
                             long watchDelay)
                      throws IgniteCheckedException

      Deprecated.
      Creates new logger with given configuration `path`.

      If `watchDelay` is not zero, created logger will check the configuration file for changes once every `watchDelay` milliseconds, and update its configuration if the file was changed. See `DOMConfigurator.configureAndWatch(String, long)` for details.

      Parameters:
        `path` - Path to log4j configuration XML file.
        `watchDelay` - delay in milliseconds used to check configuration file for changes.
      Throws:
        `IgniteCheckedException` - Thrown in case logger can't be created.

    - #### Log4JLogger

          public Log4JLogger(File cfgFile)
                      throws IgniteCheckedException

      Deprecated.
      Creates new logger with given configuration `cfgFile`. Calling this constructor is equivalent to calling `Log4JLogger(cfgFile, FileWatchdog.DEFAULT_DELAY`.
      Parameters:
        `cfgFile` - Log4j configuration XML file.
      Throws:
        `IgniteCheckedException` - Thrown in case logger can't be created.

    - #### Log4JLogger

          public Log4JLogger(File cfgFile,
                             long watchDelay)
                      throws IgniteCheckedException

      Deprecated.
      Creates new logger with given configuration `cfgFile`.

      If `watchDelay` is not zero, created logger will check the configuration file for changes once every `watchDelay` milliseconds, and update its configuration if the file was changed. See `DOMConfigurator.configureAndWatch(String, long)` for details.

      Parameters:
        `cfgFile` - Log4j configuration XML file.
        `watchDelay` - delay in milliseconds used to check configuration file for changes.
      Throws:
        `IgniteCheckedException` - Thrown in case logger can't be created.

    - #### Log4JLogger

          public Log4JLogger(URL cfgUrl)
                      throws IgniteCheckedException

      Deprecated.
      Creates new logger with given configuration `cfgUrl`. Calling this constructor is equivalent to calling `Log4JLogger(cfgUrl, FileWatchdog.DEFAULT_DELAY`.
      Parameters:
        `cfgUrl` - URL for Log4j configuration XML file.
      Throws:
        `IgniteCheckedException` - Thrown in case logger can't be created.

    - #### Log4JLogger

          public Log4JLogger(URL cfgUrl,
                             long watchDelay)
                      throws IgniteCheckedException

      Deprecated.
      Creates new logger with given configuration `cfgUrl`.

      If `watchDelay` is not zero, created logger will check the configuration file for changes once every `watchDelay` milliseconds, and update its configuration if the file was changed. See `DOMConfigurator.configureAndWatch(String, long)` for details.

      Parameters:
        `cfgUrl` - URL for Log4j configuration XML file.
        `watchDelay` - delay in milliseconds used to check configuration file for changes.
      Throws:
        `IgniteCheckedException` - Thrown in case logger can't be created.

  - ### Method Detail

    - #### isConfigured

          public static boolean isConfigured()

      Deprecated.
      Checks if Log4j is already configured within this VM or not.
      Returns:
        `True` if log4j was already configured, `false` otherwise.

    - #### setLevel

          public void setLevel(org.apache.log4j.Level level)

      Deprecated.
      Sets level for internal log4j implementation.
      Parameters:
        `level` - Log level to set.

    - #### fileName

          @Nullable
          public @Nullable String fileName()

      Deprecated.
      Gets name of the file being logged to if one is configured or `null` otherwise.
      Specified by:
        `fileName` in interface `IgniteLogger`
      Returns:
        Name of the file being logged to if one is configured or `null` otherwise.

    - #### addAppender

          public static void addAppender(org.apache.log4j.FileAppender a)

      Deprecated.
      Adds file appender.
      Parameters:
        `a` - Appender.

    - #### removeAppender

          public static void removeAppender(org.apache.log4j.FileAppender a)

      Deprecated.
      Removes file appender.
      Parameters:
        `a` - Appender.

    - #### setApplicationAndNode

          public void setApplicationAndNode(@Nullable
                                            @Nullable String application,
                                            UUID nodeId)

      Deprecated.
      Sets application name and node ID.
      Specified by:
        `setApplicationAndNode` in interface `LoggerNodeIdAndApplicationAware`
      Parameters:
        `application` - Application.
        `nodeId` - Node ID.

    - #### getNodeId

          public UUID getNodeId()

      Deprecated.
      Gets node ID.
      Specified by:
        `getNodeId` in interface `LoggerNodeIdAware`
      Returns:
        Node ID.

    - #### logFiles

          public static Collection<String> logFiles()

      Deprecated.
      Gets files for all registered file appenders.
      Returns:
        List of files.

    - #### getLogger

          public Log4JLogger getLogger(Object ctgr)

      Deprecated.
      Gets `IgniteLogger` wrapper around log4j logger for the given category. If category is `null`, then root logger is returned. If category is an instance of `Class` then `(Class)ctgr).getName()` is used as category name.
      Specified by:
        `getLogger` in interface `IgniteLogger`
      Parameters:
        `ctgr` - Category for new logger.
      Returns:
        `IgniteLogger` wrapper around log4j logger.

    - #### trace

          public void trace(String msg)

      Deprecated.
      Logs out trace message.
      Specified by:
        `trace` in interface `IgniteLogger`
      Parameters:
        `msg` - Trace message.

    - #### debug

          public void debug(String msg)

      Deprecated.
      Logs out debug message.
      Specified by:
        `debug` in interface `IgniteLogger`
      Parameters:
        `msg` - Debug message.

    - #### info

          public void info(String msg)

      Deprecated.
      Logs out information message.
      Specified by:
        `info` in interface `IgniteLogger`
      Parameters:
        `msg` - Information message.

    - #### warning

          public void warning(String msg)

      Deprecated.
      Logs out warning message.
      Specified by:
        `warning` in interface `IgniteLogger`
      Parameters:
        `msg` - Warning message.

    - #### warning

          public void warning(String msg,
                              @Nullable
                              @Nullable Throwable e)

      Deprecated.
      Logs out warning message with optional exception.
      Specified by:
        `warning` in interface `IgniteLogger`
      Parameters:
        `msg` - Warning message.
        `e` - Optional exception (can be `null`).

    - #### error

          public void error(String msg)

      Deprecated.
      Logs out error message.
      Specified by:
        `error` in interface `IgniteLogger`
      Parameters:
        `msg` - Error message.

    - #### error

          public void error(String msg,
                            @Nullable
                            @Nullable Throwable e)

      Deprecated.
      Logs error message with optional exception.
      Specified by:
        `error` in interface `IgniteLogger`
      Parameters:
        `msg` - Error message.
        `e` - Optional exception (can be `null`).

    - #### isTraceEnabled

          public boolean isTraceEnabled()

      Deprecated.
      Tests whether `trace` level is enabled.
      Specified by:
        `isTraceEnabled` in interface `IgniteLogger`
      Returns:
        `true` in case when `trace` level is enabled, `false` otherwise.

    - #### isDebugEnabled

          public boolean isDebugEnabled()

      Deprecated.
      Tests whether `debug` level is enabled.
      Specified by:
        `isDebugEnabled` in interface `IgniteLogger`
      Returns:
        `true` in case when `debug` level is enabled, `false` otherwise.

    - #### isInfoEnabled

          public boolean isInfoEnabled()

      Deprecated.
      Tests whether `info` level is enabled.
      Specified by:
        `isInfoEnabled` in interface `IgniteLogger`
      Returns:
        `true` in case when `info` level is enabled, `false` otherwise.

    - #### isQuiet

          public boolean isQuiet()

      Deprecated.
      Tests whether Logger is in "Quiet mode".
      Specified by:
        `isQuiet` in interface `IgniteLogger`
      Returns:
        `true` "Quiet mode" is enabled, `false` otherwise

    - #### toString

          public String toString()

      Deprecated.
      Overrides:
        `toString` in class `Object`

    - #### updateFilePath

          public void updateFilePath(IgniteClosure<String,String> filePathClos)

      Deprecated.
      Sets closure that later evaluate file path.
      Parameters:
        `filePathClos` - Closure that generates actual file path.

2022 Copyright © Apache Software Foundation
| Follow @ApacheIgnite
Ignite Database and Caching Platform | : ver. 2.13.0
Release Date | : April 20 2022