uCosminexus Application Server, System Setup and Operation Guide

[Contents][Glossary][Index][Back][Next]

Appendix M.7 User log functionality sample program

The userlog is provided as a sample program for confirming the operations of the user log functionality. The following table describes the files provided as samples of the source file and definition files used to execute this sample program:

Table M-4 Sample program for confirming the operations of user log functionality

File name Usage
UserLogServlet.java Servlet program of user log
UserLogHome.java Home interface
UserLog.java Remote interface
AdderEJB.java Implementation class of Enterprise Bean for calculating the total of integers.
sample.properties Sample property of logger set in the property.
MyFormatter.java Self-defined class provided as a formatter.
MyFilter.java Self-defined class provided as a filter.

The files are located in the following location.

Cosminexus-installation-directory\CC\examples\userlog

Following is the overview and the execution procedure of sample program with user log functionality:

Organization of this subsection
(1) Overview of user log functionality sample program
(2) Execution procedure of user log functionality sample program

(1) Overview of user log functionality sample program

This sample program can output the following 3 types of logs.

The following figure shows the flow of process in the sample program:

Figure M-37 Structure of user log sample program (Servlet, Enterprise Bean)

[Figure]

The log file output differs depending on the logger name and log level selected in the Input window.

(2) Execution procedure of user log functionality sample program

The following procedure describes the procedure for executing the sample program.

(a) Setting the J2EE server

See Appendix M.1(1) Setting the J2EE server.

(b) Compiling the sample file

Compile the user log samples with the batch file (compile.bat) provided in the sample.

On compiling, "myloglib.jar" file is created. Store this file in any directory to allow access to the JAR file. For details on allowing the access to the file, see 9.7.2 Method of using the container extension library in the uCosminexus Application Server Expansion Guide.

(c) Setting the property information

The property information is set in the set up server. Some contents in usrconf.properties of the set up server are rewritten in the set up file (sample.properties) provided in the sample. For building a system using Management Server, see 9.8 Setting user log output of J2EE application in the uCosminexus Application Server Expansion Guide.

The storage location of usrconf.properties and the rewritten portion in usrconf.properties file, when the set up server is "MyServer" are as follows:

The contents of sample.properties provided in the sample are as follows:

# user-log handler settings
#conf1 settings
ejbserver.application.userlog.CJLogHandler.conf1.path=userlog/logFileA
ejbserver.application.userlog.CJLogHandler.conf1.level=ALL
ejbserver.application.userlog.CJLogHandler.conf1.appname=userlog_app
ejbserver.application.userlog.CJLogHandler.conf1.formatter=com.hitachi.software.ejb.application.userlog.CJSimpleFormatter
 
#conf2 settings
ejbserver.application.userlog.CJLogHandler.conf2.path=userlog/logFileB
ejbserver.application.userlog.CJLogHandler.conf2.level=SEVERE
ejbserver.application.userlog.CJLogHandler.conf2.appname=userlog_app
 
#conf3 settings
ejbserver.application.userlog.CJLogHandler.conf3.path=userlog/logFileC
ejbserver.application.userlog.CJLogHandler.conf3.level=INFO
ejbserver.application.userlog.CJLogHandler.conf3.appname=userlog_app
 
# user-log logger settings
#logger1 settings
ejbserver.application.userlog.Logger.com.example.userlogger1.handlers=com.hitachi.software.ejb.application.userlog.CJMessageFileHandler;conf1,com.hitachi.software.ejb.application.userlog.CJMessageFileHandler;conf2
ejbserver.application.userlog.Logger.com.example.userlogger1.level=ALL
 
#logger2 settings
ejbserver.application.userlog.Logger.com.example.userlogger2.handlers=com.hitachi.software.ejb.application.userlog.CJMessageFileHandler;conf3
ejbserver.application.userlog.Logger.com.example.userlogger2.level=INFO
 
ejbserver.application.userlog.loggers=com.example.userlogger1, com.example.userlogger2

For the setting of in-process HTTP server, see Appendix M.1(2) Customizing the J2EE server.

(d) Starting the J2EE server

See Appendix M.1(3) Starting the J2EE server.

(e) Deploying the application

See Appendix M.1(5) Importing, setting and starting the application.

(f) Executing the application

Start the browser and specify the following string in the URL:

http://Machine-name :Port-number/ContextRoot/userlog.html

If the in-process HTTP server is available, the following URL is specified by default:

http://localhost/userlog/userlog_war/userlog.html

(g) Execution example of userlog

The following example shows the method of executing the userlog. The following figure shows the Select the Execution Sample Type window displayed on executing the application and specifying the URL.

Figure M-38 Select the Type of Sample to Execute window (Userlog sample program)

[Figure]

Select the type of sample to be executed and move to each data input form. The following example describes the subsequent operations on the window and method to output the log for each selected type.

When the name of the set up server is "MyServer", the resulting log file is output to the following directory by the file name set in usrconf.properties.

Cosminexus-installation-directory\CC\server\public\MyServer\logs\user\userlog
 
(h) Undeploying the application

See Appendix M.1(6) Stopping and deleting the application.

(i) Stopping the J2EE server

See Appendix M.1(7) Stopping the J2EE server.