uCosminexus Application Server, System Setup and Operation Guide
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:
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)
The log file output differs depending on the logger name and log level selected in the Input window.
The following procedure describes the procedure for executing the sample program.
See Appendix M.1(1) Setting the J2EE server.
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.
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:
: # user-log handler settings #ejbserver.application.userlog.CJLogHandler.<Specify handler-name>.path=user_log #ejbserver.application.userlog.CJLogHandler.<Specify handler-name>.count=2 : # user-log logger settings #ejbserver.application.userlog.Logger.<Specify logger-name>.handlers=<Specify handler-class> #ejbserver.application.userlog.Logger.<Specify logger-name>.useParentHandlers=true : |
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.
See Appendix M.1(3) Starting the J2EE server.
See Appendix M.1(5) Importing, setting and starting 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
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)
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
Figure M-39 Input window (Type 1: User log sample program)
Figure M-40 Display Input Result window (Type 1: User log sample program)
0310 2005/01/21 20:37:53.296 userlog_app 00922804 01000BCF Msg_100 2005/01/21 20:37:53|UserLogServlet|doPost|fatal|AAA |
0888 2005/01/21 19:41:03.609 userlog_app 00922804 009B6220 Msg_100 AAA |
Figure M-41 Input window (Type 2: User log sample program)
Figure M-42 Display Input Result window (Type 2: User log sample program)
0324 2005/01/21 20:38:59.500 userlog_app 00922804 015C998A Adder_200 2005/01/21 20:38:59|AdderEJB|add|information|inputNumber = 10 0327 2005/01/21 20:38:59.500 userlog_app 00922804 015C998A Adder_201 2005/01/21 20:38:59|AdderEJB|getTotal|information|total = 10 |
Figure M-43 Input window (Type 3: User log sample program)
Figure M-44 Display Input Result window (Type 3: User log sample program)
1077 2005/01/21 19:55:19.328 userlog_app 00922804 006458A6 Exp_300 message:Exception LEVEL:SEVERE |
See Appendix M.1(6) Stopping and deleting the application.
All Rights Reserved. Copyright (C) 2012, 2013, Hitachi, Ltd.