Issue: In WebLogic Server, the .out log files (such as nohup.out or server.out) are not rotating properly, causing them to grow significantly in size—sometimes reaching several GBs. This can lead to disk space exhaustion and make log analysis difficult.
Cause of the issue: The primary reasons for .out files not rotating are:
WebLogic Logging Configuration – The .out file is typically not managed by WebLogic’s built-in log rotation settings.
nohup or Redirected Output – If the server is started using nohup ./startWebLogic.sh &, the output is redirected to nohup.out, which does not rotate automatically.
Log Rotation Not Configured – The absence of an external log rotation mechanism (logrotate) can cause .out files to grow indefinitely.
Long Running Process – WebLogic keeps writing to the same .out file as long as the process is running.
How do we solve:
Solution 1: Enable WebLogic’s Built-in Log Rotation
If .out logs are managed via WebLogic settings, follow these steps:
Login to WebLogic Admin Console
Navigate to Servers → Select the target Managed Server.
Go to Logging Settings
Click on the Logging tab → Click on the General sub-tab.
Configure Rotation Settings
Rotate Log Files → Enabled
Rotation Type → Set to either:
By Size (100MB or as needed).
By Time (24 Hours).
Maximum Number of Retained Files → Set a limit (e.g., 10).
Save and Restart WebLogic Server
Apply changes and restart the WebLogic server for them to take effect.
Solution 2: Redirect Standard Output to a Rotating Log
Modify the WebLogic startup script to redirect logs using cronolog:
Edit startWebLogic.sh and Modify the nohup Command:
###
nohup ./startWebLogic.sh > /path/to/logs/weblogic_$(date +%Y-%m-%d).log 2>&1 &
This will create a new log file each day, preventing .out from growing indefinitely.
Conclusion: To prevent .out files from growing indefinitely, WebLogic log rotation must be configured. The best approach depends on the environment:
l Use WebLogic’s built-in log rotation if .out is managed by the server logs.
l Use logrotate if .out files are unmanaged.
l Redirect standard output with a date-based filename if rotation is not possible via WebLogic.