5-8 Oracle Fusion Middleware Using Logging Services for Application Logging for Oracle WebLogic Server
1085661942864 OBJ-0011 Test NonCatalogLogger message java.lang.Exception: Test NonCatalogLogger message
...
5.3 Using ServletContext
The servlet specification provides the following APIs in javax.servlet.ServletContext
that your servlets and JSPs can use to write a simple message to the WebLogic server log:
■
logjava.lang.String msg
■
logjava.lang.String msg, java.lang.Throwable t
For more information on using these APIs, see the Javadoc for the javax.servlet.ServletContext
interface at http:download.oracle.comdocscdE17802_
01productsproductsservlet2.3javadocjavaxservletServletCo ntext.html
. Example 5–6
illustrates JSP logging using the ServletContext.
Example 5–6 Example JSP Logging
page language=java DOCTYPE HTML PUBLIC -w3cdtd html 4.0 transitionalen
html head
titleINDEXtitle head
body bgcolor=FFFFFF config.getServletContext.logInvoked ServletContext.log From a JSP;
out.writeRequest param arg0 = + request.getParameterarg0; body
html
5.4 Configuring Servlet and Resource Adapter Logging
In this release of WebLogic Server, you can configure Web application and resource adapter logging behavior using WebLogic specific deployment descriptors. The
logging configuration deployment descriptor elements define similar attributes used to configure server logging through the LogMBean interface, such as the log file name,
location, and rotation policy.
When configured, application events are directed to a Web application specific log file. When the deployment descriptor does not include any logging configuration
information, the default behavior is to write these events in the server log file.
Similarly, WebLogic logging services are provided to Java EE resource adapters for ManagedConnectionFactory
scoped logging. You configure the log file name, location, and rotation policy for resource adapter logs through the
weblogic-ra.xml deployment descriptor. See weblogic-ra.xml Schema in
Programming Resource Adapters for Oracle WebLogic Server.
Example: Logging Configuration Deployment Descriptors
Writing Messages to the WebLogic Server Log 5-9
Example 5–7 illustrates a snippet of the deployment descriptor for configuring the
logging behavior of Web application and resource adapter logging. The elements of logging
correspond to attribute definitions on the LogMBean interface. All the LogMBean
attributes are not listed in this example. Logging configuration is defined in the WEB-INFweblogic.xml file for Web applications and in the
META-INFweblogic-ra.xml file for resource adapters.
Example 5–7 Configuring Web Application and Connector Logging
DOCTYPE weblogic-web-app PUBLIC DTD Web Application 9.0EN http:www.bea.comserverswls90dtdweblogic90-web-jar.dtd
weblogic-web-app logging
log-filenamed:\tmp\mywebapp.loglog-filename rotation-typebySizerotation-type
number-of-files-limitedtruenumber-of-files-limited file-count3file-count
file-size-limit50file-size-limit rotate-log-on-startuptruerotate-log-on-startup
log-file-rotation-dirconfigMedRecDomainWebApplog-file-rotation-dir logging
weblogic-web-app weblogic-connector xmlns=http:www.bea.comnsweblogic90
jndi-nameeis900BlackBoxNoTxConnectorjndi-name outbound-resource-adapter
connection-definition-group connection-factory-interfacejavax.sql.DataSourceconnection-factory-interface
connection-instance jndi-nameeis900BlackBoxNoTxConnectorJNDINAMEjndi-name
connection-properties pool-params
initial-capacity5initial-capacity max-capacity10max-capacity
capacity-increment1capacity-increment shrinking-enabledtrueshrinking-enabled
shrink-frequency-seconds60shrink-frequency-seconds highest-num-waiters1highest-num-waiters
highest-num-unavailable3highest-num-unavailable connection-reserve-timeout-seconds11connection-reserve-timeout-seconds
pool-params logging
log-filename900BlackBoxNoTxOne.loglog-filename logging-enabledtruelogging-enabled
rotation-typebySizerotation-type number-of-files-limitedtruenumber-of-files-limited
file-count3file-count file-size-limit100file-size-limit
rotate-log-on-startuptruerotate-log-on-startup log-file-rotation-dirc:mylogslog-file-rotation-dir
rotation-time3600rotation-time file-time-span7200file-time-span
logging properties
property nameConnectionURLname
valuejdbc:oracle:thin:bcpdb:1531:bay920value property
property
5-10 Oracle Fusion Middleware Using Logging Services for Application Logging for Oracle WebLogic Server
nameunique_ra_idname valueblackbox-notx.oracle.810value
property properties
connection-properties connection-instance
connection-definition-group outbound-resource-adapter
weblogic-connector
5.5 Writing Messages from a Client Application