Configure a JVM log rotation policy

 

  1. Identify the appserver and assign it to the server:

    set server [$AdminConfig getid /Cell:cname/Node:nname/Server:sname/]

  2. Identify the stream log and assign it to the log variable:

    set log [$AdminConfig showAttribute $server outputStreamRedirect]
    set errlog [$AdminConfig showAttribute $server errorStreamRedirect]

  3. List the current values of the stream log:

    $AdminConfig show $log

    Example output:

    {baseHour 24}
    {fileName ${SERVER_LOG_ROOT}/SystemOut.log}
    {formatWrites true}
    {maxNumberOfBackupFiles 1}
    {messageFormatKind BASIC}
    {rolloverPeriod 24}
    {rolloverSize 1}
    {rolloverType SIZE}
    {suppressStackTrace false}
    {suppressWrites false}

  4. The following example sets the rotation log file size to two megabytes:

    $AdminConfig modify $log {{rolloverSize 2}}

  5. Set the rotation policy to manage itself. It is based on the age of the file with the rollover algorithm loaded at midnight, and the log file rolling over every 12 hours:

    $AdminConfig modify $log {{rolloverType TIME} {rolloverPeriod 12} {baseHour 24}}
  6. Set the log file to roll over based on both time and size:

    $AdminConfig modify $log {{rolloverType BOTH} {rolloverSize 2} {rolloverPeriod 12} {baseHour 24}}

  7. Save changes:

    $AdminConfig save

Sample script: set_log_rotation.jacl