Limiting the growth of JVM log files using scripting



Overview

This page demonstrates how to use the AdminConfig object to modify the server configuration. Alternatively, we can use the configureJava ProcessLogs Jython script in the AdminServerManagement script library to configure the JVM log settings. The wsadmin tool automatically loads the script when the tool starts. Use the following syntax to configure JVM log settings using configureJava ProcessLogs script:

AdminServerManagement.configureJava ProcessLogs(nodeName, serverName, processLogRoot, otherAttributeList)


Configure the size of JVM log files.

Launch the wsadmin scripting tool

Run...

### Jacl...
set s1 [$AdminConfig getid /Cell:mycell/Node:mynode/Server:server1/]
set log1 [$AdminConfig showAttribute $s1 outputStreamRedirect]
set log2 [$AdminConfig showAttribute $s1 errorStreamRedirect]
$AdminConfig show $log1
$AdminConfig show $log2

### Jython...
s1 = AdminConfig.getid('/Cell:mycell/Node:mynode/Server:server1/') print s1
log1 = AdminConfig.showAttribute(s1, 'outputStreamRedirect')
log2 = AdminConfig.showAttribute(s1, 'errorStreamRedirect')
AdminConfig.show(log1)
AdminConfig.show(log2)

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}

To set the rotation policy for the stream log to two megabytes:

### Jacl...
$AdminConfig modify $log {{rolloverSize 2}}
$AdminConfig modify $log {{rolloverType TIME} {rolloverPeriod 12} {baseHour 24}}

### Jython...
AdminConfig.modify(log, ['rolloverSize', 2])
AdminConfig.modify(log, [['rolloverType', 'TIME'] ['rolloverPeriod', 12] ['baseHour', 24]])

The following example sets the log file to roll over based on both time and size:

### Jacl...
$AdminConfig modify $log {{rolloverType BOTH} {rolloverSize 2} {rolloverPeriod 12} {baseHour 24}}
AdminConfig.save()

### Jython...
AdminConfig.modify(log, [['rolloverType', 'BOTH'] ['rolloverSize', 2] ['rolloverPeriod', 12] ['baseHour', 24]])
AdminConfig.save()
AdminNodeManagement.syncActiveNodes()

Use syncNode script to propagate the changes to a specific node:

AdminNodeManagement.syncNode("myNode")

 

Related tasks

Set the JVM logs
Use the AdminConfig object for scripted administration

 

Related

Server settings configuration scripts
JVM log settings
Commands for the AdminConfig object