Benutzer:Krogmann/TestMeasuring Logging

Aus SDQ-Wiki

Java-based logging infrastructure for distributed monitoring of control and data flow of Java applications.

Logging

svn://141.3.52.13/stud/KlausKrogmann/Dissertation/code/workspace/TestMeasuring

Requirements

  • Running MySQL Server (5.0)
    • Default Settings (config/sqlsetup.properties)
      • Database running: jdbc:mysql://localhost/test
      • UserName=root
      • Password=root
    • Change my.ini file of MySQL Server and add (relates to the de.uka.ipd.sdq.logger.sql.MaxInsertStringSize property):
      • max_allowed_packet = 10M
  • Option to modify access policies (set server.policy)

Setup

  1. Start RMI registry (rmiregstart.cmd)
    • The source code path specified must not contain whitespaces!
  2. Start MySQL/DB
  3. Start Master process/Log Server (de.uka.ipd.sdq.logger.rmi.RmiLogServer.main(..))
  4. Start sensor processes (n times) / the measuring process itself
  5. Start AnalysisStarter to aggregate data

Instrumentation

place in classpath:

  • TestMeasuring.jar
  • rmi-logger.properties
  • server.policy
  • log4j-1.2.14.jar
  • mysql-connector-java-5.1.6-bin.jar
  • make the config folder available (copy into the application folder)

RMI

Example policy file granting all permissions (de.uka.ipd.sdq.logger/server.policy):

grant {
    permission java.security.AllPermission;
};

Code

class header:

// KK-Log:
import de.uka.ipd.sdq.logger.Log;
import de.uka.ipd.sdq.logger.LogFilter;
import de.uka.ipd.sdq.logger.LogPrinterFactory;
import de.uka.ipd.sdq.logger.Logger;
import de.uka.ipd.sdq.logger.enums.LogEntryItemType;
import de.uka.ipd.sdq.logger.enums.LogType;

or

// KK-Log:
import de.uka.ipd.sdq.logger.*;

class init:

// KK-Log:
private Logger myLogger = Log.getRmiLogger("sorter", this.getClass().getName());

convenient (slow) in-method-logging:

// KK-Log:
myLogger.setAutomaticLogLineAndMethodMode(true);    	
		
myLogger.newMethodInvocation(); //at the beginning of each method invocation
myLogger.addLogEntryData(LogType.MethodCall, LogDataType.ParameterValue, "obj.getItemCount", obj.getItemCount()); //logging instruction itself
..

fast in-method-logging (requires more parameters):

// KK-Log:
myLogger.newMethodInvocation(); //at the beginning of each method invocation

myLogger.addLogEntry( /* logging instruction itself */
       LogType.InIteratorStatement, /* LogType: Enum with different "places" of logger statements */
       "public int doSth(int, double) ", /* full method name like return vom Method.getName() */
       26, /* code line in the source code */
       LogDataType.Timestamp, /* Data types enum */
       "myObject", /* identifying name; e.g. the argument name */
       myObject, /* the value object itself */
       "NoComment"); /* optional comment */
..

Example

Example code for fast logging:

private de.uka.ipd.sdq.logger.Logger sdqLogger = LoggerFactory.createLogger("MyClass", "MyClass");
 
public int doSth(int c, double d) {
    sdqLogger.newMethodInvocation();
    sdqLogger.addLogEntry(LogType.MethodCall, "public int doSth(int, double) ", 15, LogDataType.ParameterValue, "d", d + "", "NoComment");
    sdqLogger.addLogEntry(LogType.MethodCall, "public int doSth(int, double) ", 15, LogDataType.ParameterValue, "c", c, "NoComment");
    
    extClass = new ExternalClass();
    int a = 0;
    for(int x = 0; x < c; x++) {
        sdqLogger.addLogEntry(LogType.InIteratorStatement, "public int doSth(int, double) ", 16, LogDataType.Timestamp, "", d, "NoComment");
    
        sdqLogger.addLogEntry(LogType.BeforeExternalAction, "public int extCallDependentReturn(int) ", 17, LogDataType.ParameterValue, "x", x, "NoComment");
        a = extClass.extCallDependentReturn(x);
        ..
    }
    ..
}

Troubleshooting

My application uses RMI and does not work together with the logging framework; the JNDI lookup of my application classes fails.

  • Check RMI ports. RMI ports should not overlap
  • Check whether there is jndi.properties in TestMeasuring.jar; remove if present.

Related Articles

User:Krogmann/TestMeasuring Monitoring