customize log file weblogic
1 posts in topic
Flat View  Flat View

Posted By:   Thomas_Chacko
Posted On:   Saturday, December 8, 2001 06:59 PM

How can I customize the log file for weblogic server. I am checking the weblogic log file to create a site access report. For this I need the information like, the browser name, the url from which the request occured. etc.
Please give me a reply ASAP.
Thanks in advance

Re: customize log file weblogic

Posted By:   Muhammad_Shakeel  
Posted On:   Monday, December 10, 2001 01:55 PM

The information you require can be retreived by calling 
appropriate methods of HttpServletRequest class's
instance in a servlet (internal request object in case of JSPs ).

To put this info. in weblogic's log file, we have to pass the request
object to a SessionBean where we will create a weblogic logger & log the
info. from there.

Here’s how you can get this info. In a JSP :

Request Method: <%= request.getMethod() %>
Request URI: <%= request.getRequestURI() %>
Request Protocol: <%= request.getProtocol() %>
Servlet path: <%= request.getServletPath() %>
Path info: <%= request.getPathInfo() %>
Path translated: <%= request.getPathTranslated() %>
Query string: <%= request.getQueryString() %>
Content length: <%= request.getContentLength() %>
Content type: <%= request.getContentType() %>
Server name: <%= request.getServerName() %>
Server port: <%= request.getServerPort() %>
Remote user: <%= request.getRemoteUser() %>
Remote address: <%= request.getRemoteAddr() %>
Remote host: <%= request.getRemoteHost() %>
Authorization scheme: <%= request.getAuthType() %>
The browser you are using is <%= request.getHeader("User-Agent") %>

Now, in a SessionBean you have to do this :

import weblogic.logging.NonCatalogLogger;

NonCatalogLogger myLogger = null;



//the argument passed is the subSystem name that will help identify
your log in weblogic logging-console while searching
myLogger = new NonCatalogLogger(“MyLoggerID”);

This will enable us to use weblogic loging from within that SessionBean
(we can use debug(), info(), warn(), and error() methods of NonCatalogLogger
class as per severity of the info. we are logging)

We can now make a method in this bean passing HttpServletRequest object as
argument, and then log the required information into weblogic’s log file.


public void logRequestInfo(HttpServletRequest request){
myLogger.info(“Request Info. :: URI : ”+ request.getRequestURI());
myLogger.info(“Request Info. :: User’s IP : ”+ request.getRemoteAddr());
myLogger.info(“Request Info. :: User’s Browser Info. : ”+ request.getHeader("User-Agent"));

Refrences :

Professional JSP (Wrox Press Ltd.)



About | Sitemap | Contact