How can someone enable NCSA access log by using wsadmin script.
To view the settings page for an HTTP channels in WAS console we follow these steps: Servers > Server Types > WebSphere application servers > server > Web Container Settings > Web container transport chains > Chain > HTTP inbound channel.
On the console, there is no administrative assistance for this task!! Thank you
Use below snippet. I have added comments for each step.
Update the first two lines - serverName and chainName as per your environment before running this.
serverName = 'server1'
chainName = 'Chain'
#update this variable to true/false to toggle logging on/off
loggingEnabled = 'true'
#Get the server id
serverId = AdminConfig.getid('/Server:%s' %(serverName))
#Get the list of all Web Container transport chains
wcTransportChains = AdminTask.listChains(AdminConfig.list("TransportChannelService", serverId), '[-acceptorFilter WebContainerInboundChannel]').splitlines()
#Iterate the list and find the chain we are interested in
for chain in wcTransportChains:
if chain.startswith(chainName):
#list all transport channles for this chain
transportChannels = AdminConfig.showAttribute(chain, 'transportChannels').split(" ")
#iterate the list and find HTTPInboundChannel to enable NCSA logging
for channel in transportChannels:
if channel.find('HTTPInboundChannel') != -1:
#Enable logging config
print ('\nEnabling NCSA logging for Transport Channel : %s on server : %s\n' %(AdminConfig.showAttribute(channel, 'name'), serverName))
AdminConfig.modify(channel, [['enableLogging', loggingEnabled]])
#end if
#end for
#end if
#end for
#save the changes
AdminConfig.save()