Tag reference sheetTag library reference for the following tag libraries:
Log4j 2 Tag Library - version 1.0The 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 <a href="http://logging.apache.org/log4j/2.x/">Log4j 2</a> 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. Namespace definition: xmlns:log="http://logging.apache.org/log4j/tld/log" Tags
Required attributes are marked with a* <log:catching>Equivalent of org.apache.logging.log4j.Logger#catching(). Can contain:empty Example<c:catch var="myException"> <%= 5 / 0 %> </c:catch> <c:if test="${myException != null}"> <log:catching exception="${myException}" /> </c:if> Attributes
<log: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. Can contain:JSP Example<log:debug message="Log this message." /> <log:debug logger="com.foo.bar" message="${objectToLog}" exception="${exception}" marker="${marker}" /> <log:debug logger="com.foo.bar" exception="${exception}" marker="${marker}"> Log this message </log:debug> Attributes
<log:dump>Displays all variables bound to the specified scope. Can contain:empty <log: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. Can contain:empty <log: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. Can contain:JSP Example<log:error message="Log this message." /> <log:error logger="com.foo.bar" message="${objectToLog}" exception="${exception}" marker="${marker}" /> <log:error logger="com.foo.bar" exception="${exception}" marker="${marker}"> Log this message </log:error> Attributes
<log:exit>Equivalent of org.apache.logging.log4j.Logger#exit(). Can contain:empty <log: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. Can contain:JSP Example<log:fatal message="Log this message." /> <log:fatal logger="com.foo.bar" message="${objectToLog}" exception="${exception}" marker="${marker}" /> <log:fatal logger="com.foo.bar" exception="${exception}" marker="${marker}"> Log this message </log:fatal> Attributes
<log:ifEnabled>Conditional tag that evaluates its body only if the specified log level and marker are enabled. Can contain:JSP Example<log:ifEnabled level="info"> Evaluate this content </log:ifEnabled> <log:ifEnabled logger="com.foo.bar" level="INFO" marker="${marker}"> Evaluate this content </log:ifEnabled> Attributes
<log: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. Can contain:JSP Example<log:info message="Log this message." /> <log:info logger="com.foo.bar" message="${objectToLog}" exception="${exception}" marker="${marker}" /> <log:info logger="com.foo.bar" exception="${exception}" marker="${marker}"> Log this message </log:info> Attributes
<log: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. Can contain:JSP Example<log:log level="warn" message="Log this message." /> <log:log logger="com.foo.bar" level="ERROR" message="${objectToLog}" exception="${exception}" marker="${marker}" /> <log:log logger="com.foo.bar" level="info" exception="${exception}" marker="${marker}"> Log this message </log:log> Attributes
<log: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. Can contain:empty Example<log:logger value="com.foo.bar" /> <log:logger value="com.bar.foo" var="myLogger" /> <log:debug message="This should log with com.foo.bar." /> <log:debug logger="${myLogger}" message="This should log with com.bar.foo." /> Attributes
<log: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. Can contain:JSP Example<log:trace message="Log this message." /> <log:trace logger="com.foo.bar" message="${objectToLog}" exception="${exception}" marker="${marker}" /> <log:trace logger="com.foo.bar" exception="${exception}" marker="${marker}"> Log this message </log:trace> Attributes
<log: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. Can contain:JSP Example<log:warn message="Log this message." /> <log:warn logger="com.foo.bar" message="${objectToLog}" exception="${exception}" marker="${marker}" /> <log:warn logger="com.foo.bar" exception="${exception}" marker="${marker}"> Log this message </log:warn> Attributes
|