Pages

Wednesday, April 8, 2015

Change Weblogic AdminServer.log, access.log and domain.log configuration using WLST script

Step1:  create a python script simple txt editor using below script, if we have more number of WLS instance then add more lines similar to below lines for each WLS instance and run the script


username ="'weblogic"
password = "xxxxx"
URL='t3://hostname.domain.com.au:7001'
connect(username,password,URL)
print "Connected successfully with Admin Server"



edit()
startEdit()










print "Domain log configuration change started"
cd('/Log/domain')
cmo.setLogFileRotationDir('/u01/app/oracle/admin/domain/cluster/logs/domain/archive')
cmo.setFileName('/u01/app/oracle/admin/domain/cluster/logs/domain/domain.log')
cmo.setRotationType('byTime')
cmo.setFileCount(30)
cmo.setRotateLogOnStartup(true)
cmo.setNumberOfFilesLimited(true)
print "Domain log configuration change end"


print "Admin server log change started"
#print '\t\t==================='+AdminServer Log Configuration Change Started +'===================='
cd('/Servers/AdminServer/Log/AdminServer')
cmo.setLogFileRotationDir('/u01/app/oracle/admin/domain/cluster/logs/AdminServer/archive')
cmo.setRotationType('byTime')
cmo.setFileCount(30)
cmo.setFileName('/u01/app/oracle/admin/domain/cluster/logs/AdminServer/AdminServer.log')
cmo.setRotateLogOnStartup(true)
cmo.setNumberOfFilesLimited(true)

cd('/Servers/AdminServer/WebServer/AdminServer/WebServerLog/AdminServer')
cmo.setRotationType('byTime')
cmo.setFileCount(30)
cmo.setFileName('/u01/app/oracle/admin/domain/cluster/logs/AdminServer/access.log')
cmo.setLogFileRotationDir('/u01/app/oracle/admin/domain/cluster/logs/AdminServer/archive')
cmo.setRotateLogOnStartup(true)
cmo.setNumberOfFilesLimited(true)

cd('/Servers/AdminServer/DataSource/AdminServer/DataSourceLogFile/AdminServer')
cmo.setLogFileRotationDir('/u01/app/oracle/admin/domain/cluster/logs/AdminServer/archive')
cmo.setRotationType('byTime')
cmo.setFileCount(30)
cmo.setFileName('/u01/app/oracle/admin/domain/cluster/logs/AdminServer/datasource.log')
cmo.setRotateLogOnStartup(true)
cmo.setNumberOfFilesLimited(true)
print "Admin server log change finished"


print "WLS_BAM1 log change Started"
cd('/Servers/WLS_BAM1/Log/WLS_BAM1')
cmo.setLogFileRotationDir('/u01/app/oracle/admin/domain/cluster/logs/WLS_BAM1/archive')
cmo.setRotationType('byTime')
cmo.setFileCount(30)
cmo.setFileName('/u01/app/oracle/admin/domain/cluster/logs/WLS_BAM1/WLS_BAM1.log')
cmo.setRotateLogOnStartup(true)
cmo.setNumberOfFilesLimited(true)

cd('/Servers/WLS_BAM1/WebServer/WLS_BAM1/WebServerLog/WLS_BAM1')
cmo.setLogFileRotationDir('/u01/app/oracle/admin/domain/cluster/logs/WLS_BAM1/archive')
cmo.setRotationType('byTime')
cmo.setFileCount(30)
cmo.setFileName('/u01/app/oracle/admin/domain/cluster/logs/WLS_BAM1/access.log')
cmo.setRotateLogOnStartup(true)
cmo.setNumberOfFilesLimited(true)

cd('/Servers/WLS_BAM1/DataSource/WLS_BAM1/DataSourceLogFile/WLS_BAM1')
cmo.setLogFileRotationDir('/u01/app/oracle/admin/domain/cluster/logs/WLS_BAM1/archive')
cmo.setRotationType('byTime')
cmo.setFileCount(30)
cmo.setFileName('/u01/app/oracle/admin/domain/cluster/logs/WLS_BAM1/datasource.log')
cmo.setRotateLogOnStartup(true)
cmo.setNumberOfFilesLimited(true)
print "WLS_BAM1 log change Finished"
activate()

Step2:  

Run the script using wlst.sh located inside WL_HOME
/u01/app/oracle/product/fmw/wlserver_10.3/common/bin/wlst.sh /scripts/changLogConfiguration/ChangeServerStartParameter_PreEnv.py

EM logs configuration changes using WLST Script




Step1:  Create a python script simple txt editor using below script, if we have more number of WLS instance then add more lines similar to below lines for each WLS instance and run the script



username ="'weblogic"
password = "xxxxx"
URL='t3://hostname.domain.com.au:7001'
connect(username,password,URL)
print "Connected successfully with Admin Server"
domainRuntime()

configureLogHandler(target="AdminServer", name="em-log-handler", rotationFrequency="daily", retentionPeriod="month", path="/u01/app/oracle/admin/domain/cluster/logs/AdminServer/emoms.log", removeProperty=['maxFileSize','maxLogSize'], baseRotationTime="2015-03-26T01:00")

configureLogHandler(target="AdminServer", name="em-trc-handler", rotationFrequency="daily",retentionPeriod="month", path="/u01/app/oracle/admin/domain/cluster/logs/AdminServer/emoms.trc", removeProperty=['maxFileSize','maxLogSize'], baseRotationTime="2015-03-26T01:00")

configureLogHandler(target="AdminServer", name="odl-handler", rotationFrequency="daily",retentionPeriod="month", path="/u01/app/oracle/admin/domain/cluster/logs/AdminServer/AdminServer-diagnostic.log", removeProperty=['maxFileSize','maxLogSize'], baseRotationTime="2015-03-26T01:00" )

configureLogHandler(target="AdminServer", name="owsm-message-handler", rotationFrequency="daily",retentionPeriod="month", path="/u01/app/oracle/admin/domain/cluster/logs/AdminServer/msglogging", removeProperty=['maxFileSize','maxLogSize'], baseRotationTime="2015-03-26T01:00")

configureLogHandler(target="AdminServer", name="soa-tracking-trc-handler", rotationFrequency="daily",retentionPeriod="month", path="/u01/app/oracle/admin/domain/cluster/logs/AdminServer/AdminServer-soa-tracking.trc", removeProperty=['maxFileSize','maxLogSize'], baseRotationTime="2015-03-26T01:00")





configureLogHandler(target="WLS_OSB1", name="em-log-handler", rotationFrequency="daily", retentionPeriod="month", path="/u01/app/oracle/admin/domain/cluster/logs/WLS_OSB1/emoms.log", removeProperty=['maxFileSize','maxLogSize'], baseRotationTime="2015-03-26T01:00")

configureLogHandler(target="WLS_OSB1", name="em-trc-handler", rotationFrequency="daily",retentionPeriod="month", path="/u01/app/oracle/admin/domain/cluster/logs/WLS_OSB1/emoms.trc", removeProperty=['maxFileSize','maxLogSize'], baseRotationTime="2015-03-26T01:00")

configureLogHandler(target="WLS_OSB1", name="odl-handler", rotationFrequency="daily",retentionPeriod="month", path="/u01/app/oracle/admin/domain/cluster/logs/WLS_OSB1/WLS_OSB1-diagnostic.log", removeProperty=['maxFileSize','maxLogSize'], baseRotationTime="2015-03-26T01:00" )

configureLogHandler(target="WLS_OSB1", name="owsm-message-handler", rotationFrequency="daily",retentionPeriod="month", path="/u01/app/oracle/admin/domain/cluster/logs/WLS_OSB1/msglogging", removeProperty=['maxFileSize','maxLogSize'], baseRotationTime="2015-03-26T01:00")

configureLogHandler(target="WLS_OSB1", name="soa-tracking-trc-handler", rotationFrequency="daily",retentionPeriod="month", path="/u01/app/oracle/admin/domain/cluster/logs/WLS_OSB1/WLS_OSB1-soa-tracking.trc", removeProperty=['maxFileSize','maxLogSize'], baseRotationTime="2015-03-26T01:00")



Step2: Run the script e.g 

/u01/app/oracle/product/fmw/Oracle_SOA1/common/bin/wlst.sh /scripts/changLogConfiguration/ChangeEMLogFileSize.py

Step3: 

Verify the EM logs from EM console 




Note:  For Detailed list of available options and property, go through below links and modify the script as per your requirement. 

http://docs.oracle.com/cd/E28271_01/web.1111/e13813/custom_logging.htm
http://docs.oracle.com/cd/E29542_01/core.1111/e10105/logs.htm#ASADM217

Also, make sure the wlst.sh which you use it must be located from Oracle_SOA1 home.

There could be possibilty that while running above script you may hit error message such as "maxFileSize" property does not exist etc because there could be some handler files which does not have size based default configuration.

Unfortunately I didn't find any simple way to ignore such error, to avoid that what I did, I first ran another script which set the size based configuration and then I ran above script which set time based rotation configuration 


configureLogHandler(target="AdminServer", name="em-log-handler", maxFileSize="10", maxLogSize="10")
configureLogHandler(target="AdminServer", name="em-trc-handler", maxFileSize="10", maxLogSize="10")
configureLogHandler(target="AdminServer", name="odl-handler",  maxFileSize="10", maxLogSize="10")
configureLogHandler(target="AdminServer", name="owsm-message-handler", maxFileSize="10", maxLogSize="10")
configureLogHandler(target="AdminServer", name="soa-tracking-trc-handler", maxFileSize="10", maxLogSize="10")