Showing posts with label Logging. Show all posts
Showing posts with label Logging. Show all posts

Thursday, June 18, 2015

How to propagate ECID from OHS to Weblogic Server

What is ECID

Execution Context ID (ECID) is a unique value assigned to each request processed by the Application Server and is used for any subsequent processing spawned from that initial request. With so many discrete components in Fusion Applications this single value is what can be used to tie the processing flow together.

After executing steps mentioned below, you will be able to see single ECID for one request in all the layers (OHS, Weblogic, WebCenter Portal, SOA etc) 

Enable the ECID and cookies logging in OHS
a. Make a backup of the httpd.conf file (in case you haven't).
This file should be located here:
[WEBTIER_INSTANCE]/config/OHS/ohs1
For example, in my case:
/u01/app/oracle/product/Middleware/11.1.1.6/asinst_2/config/OHS/ohs1
b. Edit the httpd.conf file.
c. Locate the "LogFormat" directive.
It should look like this:
LogFormat "%h %l %u %t \"%r\" %>s %b" common
d. Modify the section as follows to include the Oracle ECID and timing metric:
LogFormat "%h %l %u %t \"%r\" %>s %b ecid:%E:%R Cookie=%{Cookie}i Set-Cookie=%{Set-Cookie}o [%T (secs)]" common
e. Save the changes.
f. Stop the OHS
g. Clean all the logs from the: /data/app/admin/ohs1/diagnostics/logs/OHS/ohs1/*
h. Start the OHS.
Verification:
tail –f access_log
172.21.16.1 - - [17/Feb/2015:16:01:13 +1100] [ecid: 0053o6N^T6NBX7P6yfyWMG0007iY00000E:0] [ecid: -] Cookie=JSESSIONID=X9KVxQQM3cfvjuYVERKYIYn3OO49-ydBezDUpVHktP7dX7uMt3IW!-647353198; _WL_AUTHCOOKIE_JSESSIONID=CKUfa0-SVk3CPMHPIpgl; _ga=GA1.3.101510753.1424135093; __utmc=5569967; __utmz=5569967.1424142043.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); BIGipServerADP_WEBCTR_PORTAL_TEST2_tcp8892_pool=1376851372.48162.0000; __utma=5569967.101510753.1424135093.1424142043.1424145235.2; __utmb=5569967.17.10.1424145235; BIGipServerADP_TEST2_http_pool=1628509612.20480.0000 Set-Cookie=- "GET /portal/faces/oracle/webcenter/portalapp/pages/view1.jspx?_afrLoop=2157114934181138&_afrWindowMode=0&_afrWindowId=null HTTP/1.1" 200 6889 [0 (secs)]

Enable the ECID and Cookie logging in WLS (WCP, SOA, WCC, BPM etc)
To see the ECID on the WLS access.log, it helps to correlate better the logs and the flow.
a. Navigate to the WLS Console
b. Select Environment->Servers
c. Select the server you wish to configure
d. Click the "Logging" tab
e. Click the "HTTP" tab
f. Expand the "Advanced" section
g. Set in the "Format field" from the dropdown box "Extended", not "Common" (you may need to click on the "Lock & Edit" button - for Production mode)
h. Add "s-ip c-ip sc(X-ORACLE-DMS-ECID)" and/or "sc(Set-Cookie) cs(Cookie) time-taken" to the Extended Logging Format Fields  (by default is: date time cs-method cs-uri sc-status)
Example:
From : date time cs-method cs-uri sc-status
To:
s-ip c-ip date time sc(X-ORACLE-DMS-ECID) cs-method cs-uri sc-status sc(Set-Cookie) cs(Cookie) time-taken
i. Click the "Save" button (you may need to click on the "Activate Changes" button - for Product mode)
j. Clean all the logs from the: <DOMAIN-HOME>/servers/<MANAGED-SERVER>/logs/*
k. Restart the PORTAL managed server.

Validation :
[adpt2@adptlwc201 logs]$ tail -f access.log
#Version:       1.0
#Fields:        s-ip c-ip date time sc(X-ORACLE-DMS-ECID) cs-method cs-uri sc-status sc(Set-Cookie) cs(Cookie) time-taken
#Software:      WebLogic
#Start-Date:    2015-02-11      15:21:07
RRWC101:8892     172.26.22.24  2015-02-11      15:21:07        -       GET     /       404     -       "__utma=79138256.2059891832.1403589756.1404189723.1405037343.3; lbsid=S05Iu6ltfn87UhA25dsM265yeH-GMj_5yL47KRVzNmtKybXhjNi2!964376355!1422854433134; _ga=GA1.3.2059891832.1403589756" 0.033
Note: Please note that cookies-based-persistence is configured for top URL in the F5.

You can configure above tasks for Weblogic Server, WebCenter Portal, WebCenter Content, SOA Suite and so on as far as it has Weblogic server as a middleware. 

Thursday, February 5, 2015

Oracle Weblogic Server : Enabling Log rotation of .out file

There is no way to rotate out file from Oracle Weblogic Server Console or EM. To enable log rotation of the out log file on a Linux-based system, perform the following steps:
1. Ensure that you have the logrotate binary installed on your operating system:
ls /usr/sbin/logrotate
2. Create a logrotate configuration file (for example, under /home/oracle/ scripts/logrotate.conf) with the following contents, setting [Domain] to your domain name:
/home/oracle/SOA_DOMAIN/servers/soa_Srv01/logs/soa_Srv01.out {
missingok
copytruncate
compress
rotate=5
size=5M
}
3. Create a logrotate status file (for example, under /home/oracle/scripts/ logrotate.status) with the following contents, setting [Domain] to your domain name:
logrotate state -- version 2
"/home/oracle/SOA_DOMAIN/servers/soa_Srv01/logs/soa_Srv01.out" 2012-1-1
4. Add a new crontab entry by typing crontab -e and adding the following line:
0,15,30,45 * * * * /usr/sbin/logrotate -s /home/oracle/scripts /logrotate.status /home/oracle/scripts/logrotate.conf

This will check every 15 minutes to see if it is necessary to rotate the soa_server1.out standard out file based on the rules defined in the logrotate.conf configuration file. If new log files are added, you must ensure that they are added to the status file or they will not be rotated. This can be repeated for other managed servers as necessary.

You can run the cron job manually to test it.
/usr/sbin/logrotate -s 
/home/oracle/scripts/logrotate.status /home/oracle/scripts/logrotate.conf


Note: 
You can apply above steps for any Oracle middlware products like Oracle Weblogic Server, WbCenter, SOA, BPM, IDM etc. As this is a linux cron job, I believe its not WLS version specific.