cle_clock
Home > wikikonf >  wls/actions/by kikonf > logs







Logs

print

Action : wls.logs   (Category : wls, Name : logs, By : kikonf)
Complete Name : wls.logs.by.kikonf
Version : 4.0        License : Modified BSD License

Purpose of the wls category :
Easy to customize. This category use in background the wlst command in jython mode, to drive WebLogic Server ® configuration.
You can use it to manage the whole WebLogic ® architecture.

Purpose of this logs plugin : Tune logs parameters

The following shows the main Source Code File for the Action : wls.logs

Toggle lines
##  Copyright (c) 2008, Patrick Germain Placidoux
##  All rights reserved.
##
##  This file is part of Kikonf Public Software.
##
##  Kikonf Public Software is released under the modified BSD License,
##  which should accompany it or any part of it in the file "COPYING".
##  If you do not have this file you can access the license 
##  through the WWW at http://www.kikonf.org/license/bsd/license.txt.
## 
##  Home: http://www.kikonf.org
##  Contact: kikonf@gmx.com




from actions.wls.tools import *



class Logs(wlsAction):
            
    def extract(self, scope_attrs=None, **keywords):
        self_funct='extract'
        scope_id, scope_attrs, scope=self.getScope(scope_attrs=scope_attrs, indent=self.getIndent())
        self.verbose(scope_attrs)
        indent=self.getIndent() + 3*' '
        
        logs_node=self.newTop() #-- because in extract mode, each call returns a new blank top node.
        mkNodeScope(logs_node, scope_attrs, isUnique=True)                  
        
        verbose('Server logs:' + scope_attrs['server'] + ' retreiving.', level=self.getVerbose(), ifLevel=4, indent=self.getIndent())
        cmo=cd('/Servers/' + scope_attrs['server'] + '/Log/' + scope_attrs['server']) # Tag server
        verbose('Server logs:' + scope_attrs['server'] + ' retreived.', level=self.getVerbose(), ifLevel=3, indent=self.getIndent())        
        server_node=logs_node.newNode('server')
        extlogs(server_node, cmo)

        verbose('WebServer logs:' + scope_attrs['server'] + ' retreiving.', level=self.getVerbose(), ifLevel=4, indent=self.getIndent())
        cmo=cd('/Servers/' + scope_attrs['server'] + '/WebServer/'  + scope_attrs['server'] + '/WebServerLog/' + scope_attrs['server'])       # Tag webserver
        verbose('WebServer logs:' + scope_attrs['server'] + ' retreived.', level=self.getVerbose(), ifLevel=3, indent=self.getIndent())
        webserver_node=logs_node.newNode('webserver')
        extlogs(webserver_node, cmo, level=self.getVerbose(), indent=indent + 3* ' ')
        
        if cmo.isLoggingEnabled():
            enable_log='true'
            webserver_node.setAttr('enable_log', enable_log)

    def inject(self):
        self_funct='inject'
        logs_node = self.getTop()        
        logs_attrs = logs_node.getAttrs()
        scope_id, scope_attrs, scope=self.getScope(parent_node=logs_node, indent=self.getIndent()) #-- Retreives scope
        self.verbose(scope_attrs)
        indent=self.getIndent() + 3*' '

        cmo=cd('/Servers/' + scope_attrs['server'] + '/Log/' + scope_attrs['server'])
        if logs_node.hasNode('server'):                                         # Tag server
            verbose('Server logs:' + scope_attrs['server'] + ' retreiving.', level=self.getVerbose(), ifLevel=4, indent=self.getIndent())
            verbose('Server logs:' + scope_attrs['server'] + ' retreived.', level=self.getVerbose(), ifLevel=3, indent=self.getIndent())
            node=logs_node.getNode('server')[0]
            injlogs(node, cmo, level=self.getVerbose(), indent=indent + 2*' ')
        else:
            cmo.unSet('FileName')
            cmo.unSet('RotationType')
            cmo.setRotateLogOnStartup(False)
            cmo.unSet('FileMinSize')
            cmo.setNumberOfFilesLimited(False)
            cmo.unSet('FileCount')
            cmo.unSet('LogFileRotationDir')

        cmo=cd('/Servers/' + scope_attrs['server'] + '/WebServer/' + scope_attrs['server'] + '/WebServerLog/' + scope_attrs['server'])
        if logs_node.hasNode('webserver'):                                      # Tag webserver
            verbose('WebServer logs:' + scope_attrs['server'] + ' retreiving.', level=self.getVerbose(), ifLevel=4, indent=self.getIndent())
            verbose('WebServer logs:' + scope_attrs['server'] + ' retreived.', level=self.getVerbose(), ifLevel=3, indent=self.getIndent())
            node=logs_node.getNode('webserver')[0]            
            injlogs(node, cmo, level=self.getVerbose(), indent=indent + 2* ' ')
            
            if node.getAttr('enable_log')=='true':cmo.setLoggingEnabled(True)
            else:cmo.setLoggingEnabled(False)
        else:
            cmo.unSet('FileName')
            cmo.unSet('RotationType')
            cmo.setRotateLogOnStartup(False)
            cmo.unSet('FileMinSize')
            cmo.setNumberOfFilesLimited(False)
            cmo.unSet('FileCount')
            cmo.unSet('LogFileRotationDir')
            cmo.setLoggingEnabled(False)
            
        verbose('Server:' + scope_attrs['server'] + ' modified.', level=self.getVerbose(), ifLevel=3, indent=self.getIndent())

    def verbose(self, scope_attrs):
        scope=str(scope_attrs).replace("'", '')[1:-1]
        
        verbose('Logs at scope:' + scope + '.', level=self.getVerbose(), ifLevel=2, indent=self.getIndent())

def injlogs(node, cmo, level=None, indent=None):
    node_attrs=node.getAttrs()
    
    # - sets file_path
    if node_attrs.file_path!=None:
        cmo.setFileName(node_attrs.file_path)
        verbose('file_path', node_attrs.file_path, level=level, ifLevel=4, indent=indent )
        
    # - sets rot_type
    cmo.setRotationType(node_attrs.rot_type)
    verbose('rot_type', node_attrs.rot_type, level=level, ifLevel=4, indent=indent )

    # - sets rot_on_startup
    if node_attrs.rot_on_startup=='true':
        verbose('rot_on_startup', node_attrs.rot_on_startup, level=level, ifLevel=4, indent=indent )
        cmo.setRotateLogOnStartup(True)
    else:cmo.setRotateLogOnStartup(False)
    
    # - sets min_size
    cmo.setFileMinSize(node_attrs.min_size)
    verbose('min_size', node_attrs.min_size, level=level, ifLevel=4, indent=indent )
    
    # - sets do_limit_files
    if node_attrs.do_limit_files=='true':
        verbose('do_limit_files', node_attrs.do_limit_files, level=level, ifLevel=4, indent=indent )
        cmo.setNumberOfFilesLimited(True)
    else:cmo.setNumberOfFilesLimited(False)
    
    # - sets max_files
    cmo.setFileCount(node_attrs.max_files) 
    verbose('max_files', node_attrs.max_files, level=level, ifLevel=4, indent=indent )
    
    # - sets rot_dir
    if node_attrs.rot_dir!=None:
        verbose('rot_dir', node_attrs.rot_dir, level=level, ifLevel=4, indent=indent )
        cmo.setLogFileRotationDir(node_attrs.rot_dir)

def extlogs(node, cmo, level=None, indent=None):
    attrs={}
    
    attrs['file_path']=cmo.getFileName()
    attrs['rot_type']=cmo.getRotationType()
    if cmo.getRotateLogOnStartup():attrs['rot_on_startup']='true'
    attrs['min_size']=cmo.getFileMinSize()
    if cmo.isNumberOfFilesLimited():attrs['do_limit_files']='true'
    attrs['max_files']=cmo.getFileCount() 
    attrs['rot_dir']=cmo.getLogFileRotationDir()
    
    node.setAttrs(**attrs)
							
(Source: <KIKONF_INSTALLATION_DIR>/plugins/actions/wls/logs/by/kikonf/logs.py)


  • Line 1 to 3 say something , say something , say something
  • Line 10 to 17 say something , say something , say something , say something , say something
  • Line 20 to 25 say something



Trademarks :
  • "oracle", "Weblogic", "Weblogic Server", "Java" and "JVM" are a registred trademarks of Oracle and/or its affiliates.
  • Other names may be trademarks of their respective owners.

Copyright © 2011 - Patrick Placidoux, Hélène Malamoud