Pages

Wednesday, May 20, 2015

Remove Junk Character from Weblogic .out file !!!



Standard out file is very important log file in Weblogic domain for each of the Weblogic Server instance which gets generated from Node Manager Process. However, Weblogic des not provide any out of box facility to rotate this log file. 

Often in many implementation administrator ended up writing a custom shell script to rotate this file on certain interval using cron job or  using OS based log rotation utility such has ‘logrotate’.

SOA Administrator normally does not prefer to use the OS log rotation utility because they normally do not have root user access which required to make configuration changes for ‘logrotate’ utility, instead they prefer to write a custom shell script which can be handle using ‘oracle’ user, so that they can have full control over script customization. 

Inside that custom script very basic logic been used as below -

1)      Create a dummy file with actual WLS instance name with timestamp e.g. Output_File=WLS_OSB1.{Time_Stamp}

2)      Copy the content of original file WLS_OSB1 to dummy file e.g. cp WLS_OSB1 ${Output_File}

3)      Clear the content of current WLS_OSB1.out file e.g. cp /dev/null ${Log_File} or cat /dev/null ${Log_File} or > ${Log_File} or truncate ${Log_File} --size 0 etc.

4)      Tar the old log file e.g. tar -cvf ${Output_File}.tar ${Output_File}

5)      Move that old file to some archive location e.g. mv ${Final_Zip_File} ${Archieve_Path}
Although, above steps helps to control the growing size of .out file but it also introduce a problem as describe below which is objective of this post. 

Once WLS server instance file get rotated and WLS server tries to write first line in newly rotated file, it intermittently insert the junk character in first line, which make .out file unstable. Whenever we tries to open that file in any editor such as notepad++ or textpad etc, editor hangs because of junk character inside it. Even, if we tries to open the file using vi editor putty session get hangs.
Below snap show the file content when we tries to open from Notepad++

Notepad Editor View WLS_OSB1.out