Overview | Library | Tag | Help
| FRAMES NO FRAMES

## Log4j 2 Tag Library

Standard Syntax:
`<%@ taglib prefix="log" uri="http://logging.apache.org/log4j/tld/log" %>
`
XML Syntax:
`<anyxmlelement xmlns:log="http://logging.apache.org/log4j/tld/log" />
`

    The Log4j Log Tag Library creates the capability of inserting log
    statements in JSPs without the use of Java scripting. It uses the standard Log4j 2 API to log
    messages according to your Log4j configuration. You can learn more about Log4j 2 on the
    Log4j 2 website.

    This tag library is based on the Jakarta Commons Log Taglib by Joseph Ottinger and James
    Strachan. For the most part, logging tags written against Jakarta Commons Log Taglib should
    work against this library as well. However, the "category" attribute from Jakarta has become
    the "logger" attribute in this library.

    In accordance with the org.apache.logging.log4j.Logger API, this tag library has tags to
    support the following logging calls: "catching", "entry", "exit", "log", "trace", "debug",
    "info", "warn", "error", and "fatal". The "trace" tag was not supported in Jakarta Commons Log
    Taglib. The "setLogger", "catching", "entry", and "trace" tags are new to this library. This
    tag library also supports the conditional tag "ifEnabled" (new) and troubleshooting tag "dump"
    (existed in Jakarta Commons Log Taglib).

    By default, this tag library uses a different Logger for each JSP named after the JSP ID.
    You can customize the Logger in any of the logging tags or the "ifEnabled" tag with the
    "logger" attribute. You can also use the "setLogger" tag to specify the Logger that should apply
    for the rest of a JSP's execution. If the "setLogger" tag comes before any other logging tags in
    a JSP, the default Logger for that JSP will not be created, but instead the specified logger is
    the only one that will be used.

    Every effort was made to optimize these tags and ensure decent performance, but users of
    this library should keep in mind that the creation and execution of JSP tags adds significant
    overhead to the standard Log4j method calls. While the "trace", "debug", and "info" options are
    available in this library, their uses are not nanosecond order of magnitude with logging off
    that users may be used to with standard Log4j method calls. Therefore, they should be used
    sparingly. Use of the "ifEnabled" tag does not improve this performance; this tag is available
    to conditionally evaluate other actions in addition to logging actions.

Tag Library Information
Display Name | Log4j 2 Tag Library
Version | 1.0
Short Name | log
URI | http://logging.apache.org/log4j/tld/log

Tag Summary
setLogger | Sets the default Logger to use for the rest of this JSP's execution OR exports an org.apache.logging.log4j.Logger instance as the specified EL variable. The "value" attribute specifies either the String name of a Logger to create or an actual Logger instance. By default, Loggers are constructed and assigned the standard org.apache.logging.log4j.message.ParameterizedMessageFactory. The optional "factory" attribute can be used to override the default message factory.
ifEnabled | Conditional tag that evaluates its body only if the specified log level and marker are enabled.
catching | Equivalent of org.apache.logging.log4j.Logger#catching().
entry | Equivalent of org.apache.logging.log4j.Logger#entry(). This tag has dynamic attributes enabled. You may specify any number of arbitrary attributes whose values will be logged with this entry (TRACE) statement. The attribute names will be ignored.
exit | Equivalent of org.apache.logging.log4j.Logger#exit().
log | Equivalent of org.apache.logging.log4j.Logger#log(). This tag has dynamic attributes enabled. You may specify any number of arbitrary attributes whose values will be substituted in the String message. The "message" must be a String for this to work correctly. See the Log4j 2 manual for more information about message parameters and substitution. Only attribute values are used; attribute names are ignored.
trace | Equivalent of org.apache.logging.log4j.Logger#trace(). This tag has dynamic attributes enabled. You may specify any number of arbitrary attributes whose values will be substituted in the String message. The "message" must be a String for this to work correctly. See the Log4j 2 manual for more information about message parameters and substitution. Only attribute values are used; attribute names are ignored.
debug | Equivalent of org.apache.logging.log4j.Logger#debug(). This tag has dynamic attributes enabled. You may specify any number of arbitrary attributes whose values will be substituted in the String message. The "message" must be a String for this to work correctly. See the Log4j 2 manual for more information about message parameters and substitution. Only attribute values are used; attribute names are ignored.
info | Equivalent of org.apache.logging.log4j.Logger#info(). This tag has dynamic attributes enabled. You may specify any number of arbitrary attributes whose values will be substituted in the String message. The "message" must be a String for this to work correctly. See the Log4j 2 manual for more information about message parameters and substitution. Only attribute values are used; attribute names are ignored.
warn | Equivalent of org.apache.logging.log4j.Logger#warn(). This tag has dynamic attributes enabled. You may specify any number of arbitrary attributes whose values will be substituted in the String message. The "message" must be a String for this to work correctly. See the Log4j 2 manual for more information about message parameters and substitution. Only attribute values are used; attribute names are ignored.
error | Equivalent of org.apache.logging.log4j.Logger#error(). This tag has dynamic attributes enabled. You may specify any number of arbitrary attributes whose values will be substituted in the String message. The "message" must be a String for this to work correctly. See the Log4j 2 manual for more information about message parameters and substitution. Only attribute values are used; attribute names are ignored.
fatal | Equivalent of org.apache.logging.log4j.Logger#fatal(). This tag has dynamic attributes enabled. You may specify any number of arbitrary attributes whose values will be substituted in the String message. The "message" must be a String for this to work correctly. See the Log4j 2 manual for more information about message parameters and substitution. Only attribute values are used; attribute names are ignored.
dump | Displays all variables bound to the specified scope.

Overview | Library | Tag | Help
| FRAMES NO FRAMES

Java, JSP, and JavaServer Pages are trademarks or registered trademarks of Sun Microsystems, Inc. in the US and other countries. Copyright 2002-3 Sun Microsystems, Inc. 4150 Network Circle Santa Clara, CA 95054, U.S.A. All Rights Reserved.