8.11.3 Procedure for the user log output processing
The output of the user logs on EJB client applications is performed with the following procedure:
-
Setting system properties
The system properties are set up by using a configuration file.
-
Initializing EJB client
The log system is set up by invoking the method that initializes the EJB client functionality.
-
Executing Java logging API
The user log is output by executing the Java logging APIs.
This section describes the contents of each processing along with the procedure.
- Organization of this subsection
(1) Setting system properties
The system properties for the user log functionality of EJB client applications are set by using a configuration file.
The properties that can be set in the system properties are the keys starting with ejbserver.application.userlog, from among the properties that can be specified in usrconf.properties for J2EE servers. An example of a setting is as follows:
# user-log handler function ejbserver.application.userlog.CJLogHandler.conf1.appname=my_app1 ejbserver.application.userlog.CJLogHandler.conf1.path=application1/logfileA ejbserver.application.userlog.CJLogHandler.conf1.limit=10485760 ejbserver.application.userlog.CJLogHandler.conf1.count=2 ejbserver.application.userlog.CJLogHandler.conf1.level=SEVERE # user-log logger function ejbserver.application.userlog.Logger.com.example.userlogger1.handlers=com.hitachi.software.ejb.application.userlog.CJMPMessageFileHandler;conf1 ejbserver.application.userlog.Logger.com.example.userlogger1.useParentHandlers=true ejbserver.application.userlog.Logger.com.example.userlogger1.level=INFO ejbserver.application.userlog.loggers=com.example.userlogger1
In an EJB client application, you can specify CJMPMessageFileHandler or CJMessageFileHandler as a handler used for the user log output. You specify the handler to be used, in the ejbserver.application.userlog.Logger.logger-name.handlers key. In the example, the CJMPMessageFileHandler class is specified in the userlogger1 logger.
CJMPMessageFileHandler is a handler, which contains the functionality that enables the concurrent output of logs from multiple processes to the same file. This enables you to collect and output the user logs output by multiple processes of an EJB client application. You can use this handler only for the EJB client application.
If you do not want to concurrently output logs from multiple processes to the same file, you can also use same CJMessageFileHandler as in the case of the user log output of J2EE applications. If you use CJMessageFileHandler, the log output performance is higher as compared to the case where CJMPMessageFileHandler is used.
- Important note
-
If you use the CJMPMessageFileHandler class, Hitachi Trace Common Library creates a file used for the log management in user-log-output-directory/mmap/prefix-of-log-file-name.mm. Do not change or delete this file when you are using this user log output directory.
(2) Initializing EJB client functionality
A log system is set up by invoking the method that initializes the EJB client functionality. The EJB client functionality is initialized at one of the following timings:
-
Generating initial context of JNDI (new InitialContext method)
-
Login by the security functionality API (login method of LoginInfoManager class)
-
Acquiring objects for setting a communication timeout, in the communication timeout functionality API (getRequestTimeoutConfig method of RequestTimeoutConfigFactory class)
- Important note
-
If initialization fails, you cannot use the functionality used to output the user logs of EJB client applications. However, in the source code of a user application, you can specify and set up the J2SE standard Handler class and Logger class, or Handler class and Logger class which you created on your own, and then output the log.
(3) Executing Java logging API
In the processing in application, the Java logging API is executed and a user log is output. When using CJMPMessageFileHandler, note the following points:
- Points to be considered when using CJMPMessageFileHandler
-
When using CJMPMessageFileHandler, delay might occur until details are actually applied in the file, because a memory mapped file is used. The details are applied in the file when the process ends. However, we recommend the execution of flush if the operation continues for a long time or if delay in reflecting the contents in the file is going to cause a problem.
You use the following two methods to execute flush:
-
Invoke the flush method for all Handlers returned by the Logger.getHandlers method.
-
Specify the ejbserver.application.userlog.CJLogHandler.handler-name.autoFlush.enabled property.
If you specify the ejbserver.application.userlog.CJLogHandler.handler-name.autoFlush.enabled property, flush is automatically executed. Therefore, do not use the flush method in such cases.
-