Class JndiLookup

java.lang.Object
org.apache.logging.log4j.core.lookup.AbstractLookup
org.apache.logging.log4j.core.lookup.JndiLookup
All Implemented Interfaces:
StrLookup

@Plugin(name="jndi", category="Lookup") public class JndiLookup extends AbstractLookup
Looks up keys from JNDI resources.
  • Field Details

    • LOGGER

      private static final Logger LOGGER
    • LOOKUP

      private static final Marker LOOKUP
    • CONTAINER_JNDI_RESOURCE_PATH_PREFIX

      static final String CONTAINER_JNDI_RESOURCE_PATH_PREFIX
      JNDI resource path prefix used in a J2EE container
      See Also:
  • Constructor Details

    • JndiLookup

      public JndiLookup()
      Constructs a new instance or throw IllegalStateException if this feature is disabled.
  • Method Details

    • lookup

      public String lookup(LogEvent event, String key)
      Looks up the value of the JNDI resource.
      Parameters:
      event - The current LogEvent (is ignored by this StrLookup).
      key - the JNDI resource name to be looked up, may be null
      Returns:
      The String value of the JNDI resource.
    • convertJndiName

      private String convertJndiName(String jndiName)
      Convert the given JNDI name to the actual JNDI name to use. Default implementation applies the "java:comp/env/" prefix unless other scheme like "java:" is given.
      Parameters:
      jndiName - The name of the resource.
      Returns:
      The fully qualified name to look up.