11.0 Logging Service

 


11.1 Logging Service : An Overview

11.2 Logging ServiceMBean

11.3 Logging Levels

11.4 Setting Logging Levels

11.5 Viewing Log Files

11.6 Printing of log messages to module specific log files

11.7 Dynamically adding new logging modules and loggers at runtime

11.8 Archive Support

11.9 Customizing Logging Service


 

11.1 Logging Service : An Overview

 

At run time, agent generates log messages for the user to know about the agent processing. These log messages are stored in a text file .  Each log message has an associated log Level. The Level gives a rough idea about the importance and urgency of a log message. The user can select the level of log message to be recorded in the log file. Log messages with log level less than that chosen by the user are discarded and are not recorded in the log file.

 

Salient features of AdventNet Logging Service :

11.2 Logging Service MBean

 

AdventNet Multi-Protocol agent has implemented Logging Service as an MBean so that it may be registered in an agent and configured by remote applications. The LogFactoryController is the MBean used to configure and customize logging. The MBean enables one to configure logging at run time. The following code snippet generated in the main file is used to register this MBean.

 

//Registering the LogFactoryController MBean.
LogFactoryController logFactoryController= new LogFactoryController();
name = "Service:type=logging"; 
server.registerMBean(logFactoryController,new ObjectName(name));

 

11.3 Logging Levels

 

The AdventNet Logging Service supports the following logging levels:

11.4 Setting Logging Levels

 

You can specify the required logging level using JMX Compiler UI or using API.

 

Using JMX Compiler UI

Using API

 

The logging level can also be specified by adding the relevant code directly in the generated main file.  The following code snippet will set the log level to debug level.

      LogFactory.setLoggingLevel(debugLevel);

11.5 Viewing Log Files

11.6 Printing of log messages to module specific log files

 

To write log messages to module specific  log files, get the corresponding logger. For example, if you want to write the logging related to JMX core, to be in a file called JMX.log, please use LogFactory.getInstance("JMX","JMX.log",".").  Then use this logger for logging purposes.

 

11.7 Dynamically adding new logging modules and loggers at runtime

 

LogFactory.getInstance(String loggerName) will yield a new logger with the specified loggername.

 

11.8 Archive Support

 

Each time the agent is restarted, a separate log file is created. In some cases, we may need  to keep these log files for future reference. In order to achieve this,  the Archiving support has been added. This feature gives you the option to preserve the log files, if you wish.

 

The log files will be stored in a zip file bearing archive file name in the format <filename>.zip. The individual log file will be stored with the name in the format  <filename>_date_in_desired_format.txt. For example, if the filename is agent.txt then archive file name would be agent.zip.

 

11.9 Customizing the Logging Service

 

You can customize logging services such as changing the debug level, changing the filename/directory name, enabling/disabling logging support, etc., at agent run time. This can be done from MBean Browser/HTTP Console or using the API methods.

 

Note: To customize using MBean Browser, the browser must be started and connected to the server.

 

11.9.1 To Set Logging Level for the Multi-Protocol agent

 

You can set a logging level for the Multi-Protocol agent. This can be done either using the MBean Browser/ HTTP Console or by calling the appropriate methods.

 

11.9.1.1 Using MBean Browser/ HTTP Console

11.9.1.2 Using API

 

The following method must be called inside the agent.  The parameter int level should be any one of the logging levels explained above.

11.9.2 To Change Log File Name and Directory

 

You can change the default log file name and logging directory as per your requirement. This can be done either using the MBean Browser or by calling the appropriate methods.

 

11.9.2.2.1 Using MBean Browser

11.9.2.2.2 Using API

 

The following method must be called inside the agent.  The parameter to be passed are Log file name and the directory name.

11.9.3 To Disable Logging for a Specific Adaptor / Client

 

You can disable logging service for a specific adaptor/client. This can be done either using the MBean Browser or by calling the appropriate methods.

 

11.9.3.1 Using MBean Browser

11.9.3.2 Using API

 

The following method must be called inside the agent.  The adaptor name should be passed as the adaptor.

11.9.4 To Start and Stop the Logging Service

 

You can stop and restart the logging service at agent run time. This can be done either using the MBean Browser or by calling the appropriate methods.

 

11.9.4.1 Using MBean Browser

11.9.4.2 Using API

 

The following method must be called inside the agent.

 

Copyright © 1996-2004, AdventNet Inc. All Rights Reserved.