+

Search Tips   |   Advanced Search

 

Limiting the growth of Java virtual machine log files using scripting

 

You can use scripting to configure the size of Java virtual machine log files. Before starting this task, the wsadmin tool must be running. See the Start the wsadmin scripting client article for more information.

 

Overview

Use the following example to configure the rotation policy settings for JVM logs:

 

Procedure

  1. Identify the appserver and assign it to the server1 variable, for example:

    • Use Jacl:

      set s1 [$AdminConfig getid /Cell:mycell/Node:mynode/Server:server1/]
      

    • Use Jython:

      s1 = AdminConfig.getid('/Cell:mycell/Node:mynode/Server:server1/') print s1
      

    where:

    set Jacl command
    s1 variable name
    $ Jacl operator for substituting a variable name with its value
    AdminConfig object representing the WebSphere Application Server configuration
    getid AdminConfig command
    Cell object type
    mycell name of the object that will be modified
    Node object type
    mynode name of the object that will be modified
    Server object type
    server1 name of the object that will be modified
    print a Jython command

    Example output:

    server1(cells/mycell/nodes/mynode/servers/server1|server.xml#Server_1)
    

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

      The following example identifies the output stream log:

      • Use Jacl:

        set log [$AdminConfig showAttribute $s1 outputStreamRedirect]
        

      • Use Jython:

        log = AdminConfig.showAttribute(s1, 'outputStreamRedirect')
        

    • The following example identifies the error stream log:

      • Use Jacl:

        set log [$AdminConfig showAttribute $s1 errorStreamRedirect]
        

      • Use Jython:

        log = AdminConfig.showAttribute(s1, 'errorStreamRedirect')
        

    Example output:

    (cells/mycell/nodes/mynode/servers/server1|server.xml#StreamRedirect_2)
    

  3. List the current values of the stream log...

    • Use Jacl:

      $AdminConfig show $log
      

    • Use Jython:

      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. Modify the rotation policy for the stream log.

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

      • Use Jacl:

        $AdminConfig modify $log {{rolloverSize 2}}
        

      • Use Jython:

        AdminConfig.modify(log, ['rolloverSize', 2])
        

    • The following example sets 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:

      • Use Jacl:

        $AdminConfig modify $log {{rolloverType TIME} 
        {rolloverPeriod 12} {baseHour 24}}
        

      • Use Jython:

        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:

      • Use Jacl:

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

      • Use Jython:

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

  5. Save the configuration changes. See the Saving configuration changes with the wsadmin tool article for more information.

  6. In a network deployment environment only, synchronize the node. See the Synchronizing nodes with the wsadmin tool article for more information.



Use the AdminConfig object for scripted administration

 

Related Reference


Commands for the AdminConfig object