Wednesday, August 17, 2011

WLST, redirecting all output to a file

if you do
the result of "print" statements will still go to stdout.

If you do

from import File
from import FileOutputStream
f = File("./wlst.log")
fos = FileOutputStream(f)
print "start the script"


you will be able to send everything to the file.

The problem is how to get back to normal mode of operations... apart from restarting WLST, I mean.
One way could be
prev = theInterpreter.getOut()


Phalanx said...


This is great working script... I am looking for a feature that needs to be included in deployment automations. For development/testing environments, the frequency of deployments are quite high... I was wondering if there was a way a log the events that happen from start to end of a deployment in DEBUG mode and store it in a log file. I can send this file to the developers for troubleshooting purposes if a deployments fails or does not work as per their expectations.

I tried this solution..
but it just logs the print commands of the script. I was wondering if it can also include the java deployment logs in this...
I have been looking for a way to do this... but with my limited scripting skills I am finding it hard to find a solution... can u provide some help..



Pierluigi Vernetto said...

probably the simplest way is to launch wlst from a shell script which redirects ALL to a file:

wlst > mylog.log 2>&1

This is what I do anyway and it works so far... maybe not very elegant, but it works...