Thursday, December 1, 2011

Rotating *.out files in SOA 11g Weblogic Server

A very common issue in SOA 11g servers (Weblogic) is the inability to rotate *.out file using out of the box tools or scripts. We can rotate *.err and *.log files but not *.out files . As a result the server keeps hitting the 100% space utilization issue as the *.out file keeps grows to Gigabytes if not monitored correctly.

By default Weblogic doesn't have options to rotate the *.out file, so if we are running on Linux boxes, we can add the following snippet under /etc/logrotate.conf file and append a function to handle *.out files
(location of logs directory)/*.out {

copytruncate

rotate 5

size=10M

}
Basically the above function rotates the .out file for 5 times,once each file reaches the 10MB size and then it truncates the file.
For eg. *.out -> *.out.1 -> *.out.2 -> *.out.3 -> *.out.4 ->*.out.5 and finally *.out.5 is truncated and made to 0 bytes.

To schedule the above cleanup you can write a cron job as per your desired schedule which would call “/usr/sbin/logrotate /etc/logrotate.conf” command.

That's it !! No more 100% space utilization alerts or server crashing due to space being full.

3 comments:

  1. Any solution for this if you are running on Windows?

    ReplyDelete
  2. Does it effect the running servers??

    ReplyDelete
    Replies
    1. It operates on the .out file under your weblogic server logs directory, so yes it will rotate the .out file as soon as it hits the space specified...so it will work on your running servers as well

      Delete