The Log library allows you to embed logging calls in your JSP which can be output to a variety of destinations thanks to the power of the log4j project.
Initialising log4jBy default these log tags do not explicitly initialise log4j, you are free to do that however you wish. A common approach is to create a log4j servlet and for it to initialise log4j using some configuration file or options specified in your web.xml
My own personal preference is just to put a log4j.properties file in the WEB-INF/classes directory and for that to have your log4j configuration. Then without any special servlets or initialisation code log4j will correctly initialise itself. This approach also avoids a single web app accidentally initialising log4j several times (e.g. via 2 different servlets).
If you have any further questions regarding the configuration of log4j please visit the log4j site or a log4j specific mailing list.
Follow these steps to configure your web application with this tag library:
<taglib> <taglib-uri>http://jakarta.apache.org/taglibs/log-1.0</taglib-uri> <taglib-location>/WEB-INF/log.tld</taglib-location> </taglib>
To use the tags from this library in your JSP pages, add the following directive at the top of each page:
<%@ taglib uri="http://jakarta.apache.org/taglibs/log-1.0" prefix="log" %>
where "log" is the tag name prefix you wish to use for tags from this library. You can change this value to any prefix you like.
debug | Displays a debug-level message |
info | Displays a info-level message |
warn | Displays a warn-level message |
error | Displays a error-level message |
fatal | Displays a fatal message, usually as the application is about to terminate |
dump | Displays all vars in the specified scope |
debug | Availability: | ||||
Displays a debug-level message |
|||||
Tag Body | |||||
Restrictions | |||||
Attributes | Name | Required | Runtime Expression Evaluation | Availability | |
category | No | Yes | |||
The log4j category name used to log this message to. If this is not specified then the default log4j category is used. |
|||||
message | No | Yes | |||
The message to log. If this is not specified then the body of the tag is used instead. |
|||||
Variables | None | ||||
|
info | Availability: | ||||
Displays a info-level message |
|||||
Tag Body | |||||
Restrictions | |||||
Attributes | Name | Required | Runtime Expression Evaluation | Availability | |
category | No | Yes | |||
The log4j category name used to log this message to. If this is not specified then the default log4j category is used. |
|||||
message | No | Yes | |||
The message to log. If this is not specified then the body of the tag is used instead. |
|||||
Variables | None | ||||
|
warn | Availability: | ||||
Displays a warn-level message |
|||||
Tag Body | |||||
Restrictions | |||||
Attributes | Name | Required | Runtime Expression Evaluation | Availability | |
category | No | Yes | |||
The log4j category name used to log this message to. If this is not specified then the default log4j category is used. |
|||||
message | No | Yes | |||
The message to log. If this is not specified then the body of the tag is used instead. |
|||||
Variables | None | ||||
|
error | Availability: | ||||
Displays a error-level message |
|||||
Tag Body | |||||
Restrictions | |||||
Attributes | Name | Required | Runtime Expression Evaluation | Availability | |
category | No | Yes | |||
The log4j category name used to log this message to. If this is not specified then the default log4j category is used. |
|||||
message | No | Yes | |||
The message to log. If this is not specified then the body of the tag is used instead. |
|||||
Variables | None | ||||
|
fatal | Availability: | ||||
Displays a fatal message, usually as the application is about to terminate |
|||||
Tag Body | |||||
Restrictions | |||||
Attributes | Name | Required | Runtime Expression Evaluation | Availability | |
category | No | Yes | |||
The log4j category name used to log this message to. If this is not specified then the default log4j category is used. |
|||||
message | No | Yes | |||
The message to log. If this is not specified then the body of the tag is used instead. |
|||||
Variables | None | ||||
|
dump | Availability: | ||||
Displays all vars in the specified scope |
|||||
Tag Body | |||||
Restrictions | |||||
Attributes | Name | Required | Runtime Expression Evaluation | Availability | |
scope | Yes | Yes | |||
Variables | None | ||||
|
See the example application log-examples.war for examples of the usage of the tags from this custom tag library.
Java programmers can view the java class documentation for this tag library as javadocs.
Review the complete revision history of this tag library.