Saturday, June 20, 2015

Rotate log files


By default, when you start a WebLogic Server instance in development mode, the server automatically renames (rotates) its local server log file as SERVER_NAME.log00001, where SERVER_NAME is the name of the server. 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 using the syntax SERVER_NAME.lognnnnn, and creates a new SERVER_NAME.log to store new messages. By default, the rotated log files are numbered in order of creation using the syntax SERVER_NAME.lognnnnn, where SERVER_NAME 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.
By default, when you start a server instance in production mode, the server rotates its local log file whenever the file grows to 5000 kilobytes in size. It does not rotate the local server log file when you start the server. For more information about changing the mode in which a server starts, see Change to production mode.
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 overwrite the oldest log file.
Note: WebLogic Server sets a threshold size limit of 500 MB before it forces a hard rotation to prevent excessive log file growth.

To set up log file rotation:
1.    If you have not already done so, in the Change Center of the Administration Console, click Lock & Edit (see Use the Change Center).
2.    In the left pane, expand Environment and select Servers.
3.    In the Servers table, click the name of the server instance whose log files you want to configure for rotation.
4.    Select Logging > General.
5.    To move old messages to another file when the current log file reaches a specific size:
a.    In the Rotation Type list box, choose By Size.
b.    In the Rotation File Size field, enter the file size that triggers the server to move log messages to a separate file. After the log file reaches the specified size, the next time the server checks the file size it renames the current log file by appending a 5-digit integer; for example, SERVER_NAME.log00007. After the server renames the file, subsequent messages accumulate in a new file named SERVER_NAME.log.
c.    If you want to limit the number of log files that the server creates to store old log messages, select the Limit Number of Retained Files check box. Then in the Files to Retain field, enter the maximum number of files. If the server receives additional log messages after reaching the capacity of the last log file, it overwrites the oldest log file.
6.    If you want to move old messages to another file at specific time intervals:
a.    In the Rotation Type list box, choose By Time.
b.    In the Begin Rotation Time field, enter the start time.
Use the following format: hh:mm, where hh is the hour in a 24-hour format and mm is the minute. At the time that you specify, the server rotates the current log file. If the time that you specify is already past, the server rotates the log file at the next scheduled interval, as specified in Rotation Interval.
c.    In the Rotation Interval field, enter the interval at which the server saves old messages to another file.
d.    If you want to limit the number of log files that the server creates to store old log messages, select the Limit Number of Retained Log Files check box. Then in the Files to Retain field, enter the maximum number of files. If the server receives additional log messages after reaching the capacity of the last log file, it overwrites the oldest log file.
7.    In the Log File Rotation Directory field, enter the directory location where the rotated log files will be stored.
Enter an absolute pathname or a pathname that is relative to the server's root directory. By default, the rotated files are stored in the same directory where the log file is stored.
For more information, see A Server's Root Directory.
8.    To include a time and date stamp in the file name when the log file is rotated, in the File Name field, add java.text.SimpleDateFormat variables to the file name and surround each variable with percentage (%) characters.
For example, if you enter the following value in the File Name field: myserver_%yyyy%_%MM%_%dd%_%hh%_%mm%.log, the server's log file will be named myserver_yyyy_MM_dd_hh_mm.log.
When the server instance rotates the log file, the rotated file name contains the date stamp. For example, if the server instance rotates its local log file on 4 March, 2005 at 10:15 AM, the log file that contains the old log messages will be named myserver_2005_03_04_10_15.lognnnnn. (The current, in-use server log file retains the name myserver_yyyy_MM_dd_hh_mm.log.)
If you do not include a time and date stamp, the rotated log files are numbered in order of creation SERVER_NAME.lognnnnn, where SERVER_NAME is the name configured for the log file. For example: myserver.log00007.
9.    To activate these changes, in the Change Center of the Administration Console, click Activate Changes.
Not all changes take effect immediately—some require a restart 

No comments:

Post a Comment