Friday, December 14, 2012

How to Configure Logging Using Weblogic Scripting Tool

Weblogic Scripting Tool (WLST) is a command-line tool that runs on the same machine as the Weblogic server and allows the user to browse the configuration and state of the server through a tree of mbeans (managememnt beans).  It is based on the Java scripting interpreter, Jython.

Using WLST, you can configure a server instance’s logging and message output.  To determine which log attributes can be configured, see LogMBean and LogFileMBean in the WebLogic Server MBean Reference[1].

In this article, we first show you how to configure log attributes from WebLogic Server Administration Console and then show you how to set attributes of LogMBean using WLST.

Modifying Attribute from WLS Console


To bring WLS Administration Console up, you type the following address into your browser's address field:
  • http://<myserver>:7001/console
and log in with your credentials (say, "weblogic/weblogic1").  To modify "Rotation file size" of the log attribute, you do:
  • Click "Lock & Edit"
  • Select and Click:
    • Environment > Servers > CRMDemo_server1 > Logging
You modify "Rotation file size" to be a different value and then activate your change.  



Next to the "Rotation file size" field, you can click on "More Info..." to see its detailed description.

As you can see, "Rotation file size" field is linked to the following MBean Attibute:
  • LogMBean.FileMinSize

Modifying Attribute from WLST


Instead of modifying log attributes from the console, you can also achieve it by using WLST.

$cd $MW_HOME/wlserver_10.3/common/bin
$./wlst.sh
wls:/offline> connect("weblogic","weblogic1", "t3://localhost:7001")  
wls:/atgdomain/serverConfig> cd("Servers/CRMDemo_server1/Log/CRMDemo_server1")
wls:/atgdomain/serverConfig/Servers/CRMDemo_server1/Log/CRMDemo_server1> ls()
dr--   DomainLogBroadcastFilter
dr--   LogFileFilter
-r--   FileMinSize                                  5000
-r--   FileName                                     logs/CRMDemo_server1.log
 .
 .
 .
-r-x   unSet                                        Void : String(propertyName)

As shown above, this is what happened:
  1. We connected to the server
  2. We set Current Management Object (CMO) to the server log config
  3. We listed all LogMBean attributes
  4. Our log attribute FileMinSize was shown on the list
To modify "FileMinSize" log attribute, you can create a script (i.e., setFileMinSize.py) such as:

# Connect to the server
connect("weblogic","weblogic1","t3://localhost:7001")
edit()
startEdit()
# set CMO to the server log config
cd("Servers/CRMDemo_server1/Log/CRMDemo_server1")
ls()
# change LogMBean attributes
set("FileMinSize", 400)
# list the current directory to confirm the new attribute values
ls()
# save and activate the changes
save()
activate(block="true")
# all done...
exit()

No comments:

Post a Comment