You are not logged in. Click here to log in.

Application Lifecycle Management

Search In Project

Search inClear

Tags:  not added yet

Component Logging

Specifying component logging levels using the OMS DSL element 'logging' in the simulation file

Concept

Logging level can be specified for each component in the model, or for the package (of components). The four levels are 'INFO', 'FINE', 'FINER', and 'FINEST', with 'INFO' the default logging level. The levels are hierarchical in the sense that 'FINEST' contains more detailed information plus the information of the previous three levels, 'FINER' the previous two levels, and so on.

Implementation

In this example, a logger is used in the component and the level is controlled in the simulation script. The OMS DSL 'logging' element allows assigning different log levels to packages and components. 'Component' gets the component name and adds it to an 'oms3.model.' string, then executes logging for the logging level specified in the simulation file.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package ex08;

import java.util.logging.Logger;
import oms3.annotations.*;

/**
 *
 * @author od
 */
public class Component {

    // static logger for this class
    static final Logger log = Logger.getLogger("oms3.model." +
            Component.class.getName());

    @In public String message;

    @Execute
    public void run() {
        // use the logger here
        log.info(message);
        log.fine(message);
        log.finer(message);
        log.finest(message);
    }
}

A logging level of 'FINE' is set in the simulation file. The one component model consumes the message parameter 'logging greeting...' then prints out 'INFO' level log information and repeats with 'FINE' level log information.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
import static oms3.SimBuilder.instance as OMS3

OMS3.sim {
    model {
       parameter {
           'c.message' "logging greeting ..."
       }

       components {
           'c' 'ex08.Component'
       }

       // logging element for controlling log levels 
       // for components 
       logging {

            // set the loglevel here 
            // 'component class name' -> 'log level' (ALL|SEVERE|WARNING|...)
            'ex08.Component' 'FINE'
        }
    }
}