Tuesday, April 21, 2015

ADF Logging in Different Applications Deployed on Managed Server

There are many detailed useful blogs on ADF Logging which provide full details on understanding the details and how to implement and configure it.

This post is for my future reference as how to enable/configure ADF Logging for multiple applications deployed on Weblogic Managed Server.

Use Case : Enable ADF Logging for multiple applications deployed on Weblogic Managed Server.

Lets Get Started.

Important thing to understand here is that for ADF Logging to be implemented correctly Package Structure for the application plays a very important role. So as a common/best practice , package structures should be defined correctly for all the Managed Beans/Java Classes in the application. Also packages structures should be able to differentiate the ManagedBeans/Java Classes in different applications.

Ideally a unique root package name for the application should be given at project creation time in Jdeveloper.



Ok lets start implementing.

Created two ADF Applications. PayRollApp and PartnerApp. Both applications have below mentioned root packages.

PayRollApp : com.company.payroll

PartnerApp : com.comapny.partner

Created a PartnerTest.jspx in PartnerApp having a button which has an actionListener method which logs the log messages.





PartnerMB Managed Bean



Same for PayRoll application - PayRollTest.jspx and PayRollMB.



Now we need to configure logging. Logging is configured in logging.xml

It is present at Domain_Name\config\fmwconfig\servers\Server_Name

In the logging.xml there are alot of handlers. We will create two more odl-handler and will give a file path to create logs. Below is loggin.xml with two new handlers. "payroll-handler" and "partner-handler"



The log handlers are in place. Path property defines the custom path and file name for the log file. We need to define the loggers which will use these handlers. So payroll-handler will be used by payroll Logger and partner-handler will be used by partner-handler.

Point to keep in mind here is that Logger name is the package name which is being used by the application and all the classes under that package name will be Logged.

So added below loggers in logging.xml at the bottom.



Currently the logger level is INFO.


Deploy both the Applications on Managed Server(Server Name) for which loggin.xml is modified.

Run both the PayRollTest.jspx and PartnerTest.jspx and click on button invoke logging code in the Managed Bean.
PartnerTest.jspx 


PayRollTest.jspx

The Logs files for both applications are generated and can be seen at the path given while defining handler and it is logging for individual applications.

Domain_Name\servers\Server_Name\logs
partner-diagnostic.log
payroll-diagnostic.log

Below is the log from Partner Application.

[2015-04-21T12:06:13.890+08:00] [DefaultServer] [NOTIFICATION] [] [com.comapny.partner.view.bean.PartnerMB] [host: OAB-7KMJL12] [nwaddr: 10.3.20.122] [tid: 15] [userId: <anonymous>] [ecid: 0000bb6cb1d4df40:78875660:14cda01487c:-8000-000000000000011c,0] [APP: PartnerApp] This is Info Message from Partner Application


Thats it. Same approach can be used in Real Time Implementation projects!!


10 comments:

  1. Very useful documents. I think it will help all ADF developer ...Thanks a lot Rohan...Keep it up..Waiting for more useful post !.....

    ReplyDelete
  2. Thanks Rohan. LOGGER.info works for me but if I have LOGGER.log doesn't work; any pointers?

    ReplyDelete
  3. Thanks Sfti.
    For logger.info to work use logger.info(java.util.logging.Level, String) signatures.Example :- logger.log(Level.INFO,"This message is from logger.log() method"); This will work.

    Thanks
    Rohan

    ReplyDelete
  4. Thanks for the reply Rohan. Is there anyway (logging.xml changes or at server) I can make it work without modifying the existing code? I can't modify logger.log(Level.INFO, in all the class files.

    ReplyDelete
  5. Yes, you can do this either by EM or by using WLST commands to change the log levels without even touching logging.xml Refer : http://docs.oracle.com/cd/E23943_01/core.1111/e10105/logs.htm#ASADM233

    Thanks
    Rohan

    ReplyDelete
  6. The information which you have provided is really nice and awesome. Provides some very useful insights of how things actually work. I want to share something more about this as well.
    software development company

    ReplyDelete
  7. Very helpfull Rohan.Expecting more from you.

    ReplyDelete
  8. DreamHost is definitely one of the best web-hosting provider with plans for any hosting requirments.

    ReplyDelete
  9. Thank you for such a informative article.

    ReplyDelete