Oracle Server E10293-02 User Manual
Event Processing in Log4j
C-4
Oracle Communication and Mobility Server Developer’s Guide
The isEnabled method returns true only if the Log4j filter is configured so that a
call to logEvent method with the same argument is logged.
call to logEvent method with the same argument is logged.
illustrates
how a servlet uses the Accounting Event API to log events for all of its requests and
responses.
responses.
Example C–2
Logging Events with the Accounting API
public class EventTestServlet extends SipServlet
{
private EventLogger eventLogger;
public void init() {
ServletContext sc = getServletContext();
EventLoggerFactory factory = (EventLoggerFactory) sc
.getAttribute(
"
oracle.sdp.sipservlet.EventLoggerFactory
"
);
eventLogger = factory.getLogger(EventTestServlet.class);
}
public void doRequest(SipServletRequest req) {
if (eventLogger.isEnabled(req)) {
eventLogger.logEvent(req, null);
}
URI requestURI = req.getRequestURI();
req.getProxy().proxyTo(requestURI);
}
public void doResponse(SipServletResponse resp) {
if (eventLogger.isEnabled(resp)) {
Map additional = new HashMap();
additional.put(
"
foo
"
,
"
bar
"
)
eventLogger.logEvent(resp, additional);
}
}
}
Event Processing in Log4j
Log4j is executes the following tasks:
■
Event filtering
■
Event formatting
■
Deciding the destination for events
These configurations can be changed in runtime by editing the Log4j configuration file
(log4j.xml).
(log4j.xml).
For more information about Log4j, see
http://logging.apache.org/log4j
.
Table C–3
Attributes of the logEvent(Map <Object, Object> event, String category)
Method
Attribute Key
Description of attribute value
Service
The name of the service generating the event (that is, the full
Log4j category name).
Log4j category name).