SAS 9.1.3 Integration Technologies » Developer's Guide


Developing Java Clients
Installation and JRE Requirements
Security
Using the IOM Server
Using the Java Connection Factory
Connecting with Directly Supplied Server Attributes
Connecting with Server Attributes Read from a SAS Metadata Server
Connecting with Server Attributes Read from an LDAP Server
Connecting with Server Attributes Read from the Information Service
Language Service Example
Logging Java Connection Factory Activities
Using Failover
Using Load Balancing
Using Connection Pooling
Pooling with Directly Supplied Server Attributes
Pooling with Server Attributes Read from a Metadata Server
Pooling with Server Attributes Read from the Information Service
Returning Connections to the Java Connection Factory
Using Java CORBA Stubs for IOM Objects
Getting a JDBC Connection Object
Using the Java Workspace Factory
Using SAS Foundation Services
IOM and CORBA Class Documentation
Java Clients

Logging Java Connection Factory Activity

If you connect using the PlatformConnectionFactory class, logging is handled by the Logging Service component of SAS Foundation Services. The logging context for a Java Connection Factory is "com.sas.services.connection". For more information about the Logging Service, see Modifying the Logging Service Configuration in the SAS Integration Technologies: Administrator's Guide and com.sas.services.logging in the Foundation Services class documentation.

If you are connecting using the ConnectionFactory class, logging is handled by the java.util.logging package. The Java Connection Factory writes diagnostic and status messages to the console by default. These messages will be useful for debugging or performance monitoring.

Note: The following sections apply to the ConnectionFactory class only.

Changing the Message Level

To change the types of messages that are logged, create a Logger object using the Logger.getLogger() method in java.util.logging, then use the setLevel() method to set the level of messages that the logger uses. The default message level is INFO.

The following code fragment specifies that detailed tracing messages should be logged in addition to the default messages:

import java.util.logging.*;
ConnectionFactoryManager cxfManager = new ConnectionFactoryManager(); 
ConnectionFactoryConfiguration cxfConfig = ...
String loggerName = cxfManager.getFactoryLoggerName(cxfConfig);
Logger logger = Logger.getLogger(loggerName);
logger.setLevel(Level.FINEST);

The following code fragment specifies that no messages are logged:

import java.util.logging.*;
ConnectionFactoryManager cxfManager = new ConnectionFactoryManager(); 
ConnectionFactoryConfiguration cxfConfig = ...
String loggerName = cxfManager.getFactoryLoggerName(cxfConfig);
Logger logger = Logger.getLogger(loggerName);
logger.setLevel(Level.OFF);

Logging to a File

To log messages to a file, create a FileHandler object using the constructor method in java.util.logging and add it to your connection factory's Logger object.

The following code fragment specifies that verbose messages are logged to a file and console logging is disabled:

import java.util.logging;
ConnectionFactoryManager cxfManager = new ConnectionFactoryManager(); 
ConnectionFactoryConfiguration cxfConfig = ...
String loggerName = cfxManager.getFactoryLoggerName(cxfConfig);
Logger logger = Logger.getLogger(loggerName);
logger.setLevel(Level.FINEST);
FileHandler handler = new FileHandler("file-path");
handler.setLevel(Level.FINEST);
logger.addHandler(handler);
logger.setUseParentHandlers(false);

Note:   If you do not specify setUseParentHandlers(false), messages are sent to both the log file and the console.