Rotating WebLogic Server logs to avoid large files using WLST.
By adejuanc on Oct 09, 2012
By default, when WebLogic Server instances are started in development
mode, the server automatically renames (rotates) its local server log
file as SERVER_NAME.log.n. For the remainder of the server session, log
messages accumulate in SERVER_NAME.log until the file grows to a size
of 500 kilobytes.
Each time the server log file reaches this size, the server renames the log file and creates a new SERVER_NAME.log to store new messages. By default, the rotated log files are numbered in order of creation filenamennnnn, where filename is the name configured for the log file. You can configure a server instance to include a time and date stamp in the file name of rotated log files; for example, server-name-%yyyy%-%mm%-%dd%-%hh%-%mm%.log.
By default, when server instances are started in production mode, the server rotates its server log file whenever the file grows to 5000 kilobytes in size. It does not rotate the local server log file when the server is started. For more information about changing the mode in which a server starts, see Change to production mode in the Administration Console Online Help.
You can change these default settings for log file rotation. For example, you can change the file size at which the server rotates the log file or you can configure a server to rotate log files based on a time interval. You can also specify the maximum number of rotated files that can accumulate. After the number of log files reaches this number, subsequent file rotations delete the oldest log file and create a new log file with the latest suffix.
Note: WebLogic Server sets a threshold size limit of 500 MB before it forces a hard rotation to prevent excessive log file growth.
To Rotate via WLST :
#connect WLST to an Administration Servera
#navigate to the ServerRuntime MBean hierarchy
#navigate to the server LogRuntimeMBean
-r-- Name myserver
-r-- Type LogRuntime
-r-x forceLogRotation java.lang.Void :
#force the immediate rotation of the server log file
The server immediately rotates the file and prints the following message:
<Mar 2, 2012 3:23:01 PM EST> <Info> <Log
Management> <BEA-170017> <The log file
C:\diablodomain\servers\myserver\logs\myserver.log will be rotated.
Reopen the log file if tailing has stopped. This can happen on some
platforms like Windows.>
<Mar 2, 2012 3:23:01 PM EST> <Info> <Log Management> <BEA-170018> <The log file has been rotated to C:\diablodomain\servers\myserver\logs\myserver.log00001. Log messages will continue to be logged in C:\diablodomain\servers\myserver\logs\myserver.log.>
To specify the Location of the archived Log Files
The following command specifies the directory location for the archived log files using the -Dweblogic.log.LogFileRotationDir Java startup option:
For more information read the following documentation ;
Using the WebLogic Scripting Tool
Configuring WebLogic Logging Services