Diagram 1. Main Server Logger Overview

Diagram 2. Microservice - Local Server Logger Overview

JLupin Next Server consists of the following logging mechanism

1) Start-up loggers - inner starting server's loggers

2) Execution time loggers (running loggers) - of externals, implementation dependants, configurations, applications, etc.

Explain them:

1) Start-up loggers

Start-up loggers log information during the start-up process. They log the server's and given applications' information.

1.1) Main Server Start-up Logger

The global server logs to the following file in this path: SERVERHOME/logs/server/global/start/initialize_YYYY_MM-DD_HH_MM_SS.txt Logging levels: INFO, DEBUG, ERROR, WARN, STACK. Class loaders log information inn the aforementioned directory as well - this is particularly important for debugging problems with class loading. Setting the global server logging level takes place in the start-up file: start.cmd, start.sh. The last parameter is precisely responsible for the logging level:

The start.cmd file

%JLUPIN_JAVA_EXE% %JAVA_OPTS% -cp %JLUPIN_CLASSPATH% com.jlupin.starter.global.JLupinGlobalServerStarter serverStart JLupinGlobalMultiProcessConfigurationImpl.java consoleCommandModeOn startApplicationParallelModeOff INFO

The start.sh file
"$JLUPIN_JAVA_EXE" $JAVA_OPTS -classpath $JLUPIN_CLASSPATH com.jlupin.starter.global.JLupinGlobalServerStarter serverStart JLupinGlobalMultiProcessConfigurationImpl.java consoleCommandModeOn startApplicationParallelModeOn DEBUG

1.2) Microservice - Local server's start-up logger (of the application)

The local server logs to the following paths: SERVERHOME/logs/server/local/APPLICATIONNAME/start initialize YYYY_MM-DD_HH_MM_SS.txt. Logging level: INFO, DEBUG, ERROR, WARN, STACK. Setting the local server's logger level takes place in the global server's JLupinGlobalMultiProcessConfigurationImpl configuration file .

Observe the proper code fragment – method: public JLupinMultiProcessManager getJLupinMultiProcessManager() ;

@Override
    public JLupinMultiProcessManager getJLupinMultiProcessManager() {

        JLupinLocalServerProcessConfigurator jLupinFirstSampleApplication =
                                             new JLupinLocalServerProcessConfigurator();
        jLupinFirstSampleApplication.setLocalServerName("localhost");
        jLupinFirstSampleApplication.setPrimaryPort(18088);
        jLupinFirstSampleApplication.setSecondaryPort(18089);
        jLupinFirstSampleApplication.setPrimaryCommandPort(19088);
        jLupinFirstSampleApplication.setSecondaryCommandPort(19099);
        jLupinFirstSampleApplication.setConnectionSocketTimeout(30000);
        jLupinFirstSampleApplication.setStartLogMode("DEBUG");
        jLupinFirstSampleApplication.setWaitForProcessStartResponseTime(65000);
        jLupinFirstSampleApplication.setWaitForProcessDestroyResponseTime(10000);
        jLupinFirstSampleApplication.setPrimaryJvmOptions("-Xms128M -Xmx256M");
        jLupinFirstSampleApplication.setSecondaryJvmOptions("-Xms128M -Xmx256M");
        jLupinFirstSampleApplication.setConfigurationClassFileName(
                                     "JLupinFirstSampleApplicationConfigurationImpl.java");

        JLupinLocalServerProcessConfigurator jLupinSecondSampleApplication =
                                             new JLupinLocalServerProcessConfigurator();
        jLupinSecondSampleApplication.setLocalServerName("localhost");
        jLupinSecondSampleApplication.setPrimaryPort(20078);
        jLupinSecondSampleApplication.setSecondaryPort(20079);
        jLupinSecondSampleApplication.setPrimaryCommandPort(21078);
        jLupinSecondSampleApplication.setSecondaryCommandPort(21079);
        jLupinSecondSampleApplication.setConnectionSocketTimeout(30000);
        jLupinSecondSampleApplication.setWaitForProcessStartResponseTime(45000);
        jLupinSecondSampleApplication.setWaitForProcessDestroyResponseTime(10000);
        jLupinSecondSampleApplication.setPrimaryJvmOptions("-Xms128M -Xmx256M");
        jLupinSecondSampleApplication.setSecondaryJvmOptions("-Xms128M -Xmx256M");
        jLupinSecondSampleApplication.setConfigurationClassFileName(
                                      "JLupinSecondSampleApplicationConfigurationImpl.java");

        JLupinDefaultNewMultiProcessManagerImpl jLupinDefaultMultiProcessManagerImpl =
                new JLupinDefaultNewMultiProcessManagerImpl();

        jLupinDefaultMultiProcessManagerImpl.addApplicationConfiguration("firstSampleApplication",
                jLupinFirstSampleApplication);

        jLupinDefaultMultiProcessManagerImpl.addApplicationConfiguration("secondSampleApplication",
                jLupinSecondSampleApplication);

        return jLupinDefaultMultiProcessManagerImpl;
    }

Observe the important line of code:

jLupinFirstSampleApplication.setStartLogMode("DEBUG");

The startLogMode variable decides which logging level of the start-up logger is used. If the proper level is not set then the application (local server) is started in INFO level.

Local server logs to the other file as well. SERVERHOME/logs/server/local/APPLICATIONNAME/start std_out_and_err_during_start_YYYY_MM_DD_HH_MM_SS.VERSION.VERSION.txt. This file contains all information which are logged by System.out.print and System.out.println methods during objects' initialization in an application container (see chapter about application's containers). This Information is also given to the global server's main console.

2) Execution time loggers

Execution time loggers are the implementation of the JLupinLogger interface.
The following shows interface code:

public interface JLupinLogger {

       public void beforeLog();
       public void afterLog();
       public void log      (int messageIdentifier, LogMode logMode, Object  message);
       public void log      (int messageIdentifier, LogMode logMode, Object message, Object [] messageParams);
       public void log      (int messageIdentifier, LogMode logMode, Object message, Throwable th);
       public void log      (int messageIdentifier, LogMode logMode, Object message, Object [] messageParams,
                                                                                     Throwable th);

       public void log      (LogMode logMode, Object message);
       public void log      (LogMode logMode, Object message, Object [] messageParams);
       public void log      (LogMode logMode, Object message, Throwable th);
       public void log      (LogMode logMode, Object message, Object [] messageParams, Throwable th);

       public void info      (Object message);
       public void info      (Object message, Object [] messageParams);
       public void info      (Object message, Throwable th);
       public void info      (Object message, Object [] messageParams, Throwable th);

       public void debug      (Object message);
       public void debug      (Object message, Object [] messageParams);
       public void debug      (Object message, Throwable th);
       public void debug      (Object message, Object [] messageParams, Throwable th);

       public void error      (Object message);
       public void error      (Object message, Object [] messageParams);
       public void error      (Object message, Throwable th);
       public void error      (Object message, Object [] messageParams, Throwable th);

       public void warn       (Object message);
       public void warn       (Object message, Object [] messageParams);
       public void warn       (Object message, Throwable th);
       public void warn       (Object message, Object [] messageParams, Throwable th);
       public LogMode         getLogMode();

}

2.1) Start time logger of the global server

The JLupinLogger interface's implementations are included in the global server: JLupinLoggerOverLog4jImpl and JLupinSimpleGlobalServerLoggerImpl. The definition of the execution time logger is found in the JLupinGlobalMultiProcessConfigurationImpl file in the getJLupinLogger method .

Let us discuss them.

2.1.1) JLupinLoggerOverLog4jImpl

Look at the relevant code fragment:

    @Override
    public JLupinLogger getJLupinLogger() {
        return JLupinLoggerOverLog4jImpl.getInstance();
    }

The JLupinLoggerOverLog4jImpl implementation for the global server reads its configuration from the log4j.xml file which is delivered by the server. This file is located in SERVERHOME/server-resources. The path to the logging file in aforementioned file looks as follow:

"File" value="../logs/server/global/run/jlupinnextserver_running_log.txt"/>

2.1.2) JLupinSimpleGlobalServerLoggerImpl

Observe the proper fragment:
    @Override
    public JLupinLogger getJLupinLogger() {
        JLupinSimpleGlobalServerLoggerImpl.initializeWithLogMode(LogMode.DEBUG);
        return JLupinSimpleGlobalServerLoggerImpl.getInstance();
    }

The JLupinSimpleGlobalServerLoggerImpl implementation logs to exactly the same path as JLupinLoggerOverLog4jImpl that is SERVERHOME/logs/server/global/run/jlupinnextserver_running_log.txt. In case of JLupinSimpleGlobalServerLoggerImpl, logging level is set in the following method JLupinSimpleGlobalServerLoggerImpl.initializeWithLogMode(LogMode.DEBUG);

2.2) Execution time logger of the local server

Files of the execution time logger log everything what will be logged in the application with the help of the JLupinLoggera implementation. In order to get the logger in the application's code, the client has to execute the following method

JLupinLogger jLupinLogger = JLupinRuntimeContainer.getInstance().getJLupinLogger();

The jLupinLogger variable contains the logger which is defined in the application's configuration file. We include the following to the implementation of the JLupinLogger interface of the global server: JLupinLoggerOverLog4jImpl and JLupinSimpleApplicationLoggerImpl. The definition of the execution time loggers is found in a configuration file of the specific application in the getJLupinLogger method. For the purpose of this chapter, we will use the application's 'firstSampleApplication' configuration file which is supplied with the server - JlupinFirstSampleApplicationConfigurationImpl. Let us discuss them. For the purpose of this chapter, we will use the application's 'firstSampleApplication' configuration file which is supplied with the server - JlupinFirstSampleApplicationConfigurationImpl.

2.2.1) JLupinLoggerOverLog4jImpl

Observe the proper fragment in the JlupinFirstSampleApplicationConfigurationImpl file:

    @Override
    public JLupinLogger getJLupinLogger() {
        return JLupinLoggerOverLog4jImpl.getInstance();
    }

The JLupinLoggerOverLog4jImpl implementation for the global server reads its configuration from configuration files located in the application's directory. In case of the 'firstSampleApplication' test application it will be the file in: SERVERHOME/application/firstSampleApplication/log4j.xml location. The path to the logging file in the aforementioned file appears as the follow:

"File" value="../logs/server/local/firstSampleApplication/run/sample.log"/>

By using the Log4j logger directly in application's source code, the client has certainty that attributes and parameters of logging mechanism will be read from the log4j.xml or log4j.properties files from application's directory.

2.1.2) JLupinSimpleApplicationLoggerImpl

Observe the proper fragment:

    @Override
    public JLupinLogger getJLupinLogger() {
        JLupinSimpleApplicationLoggerImpl.initializeWithLogMode(LogMode.DEBUG);
        return JLupinSimpleApplicationLoggerImpl.getInstance();
    }

The JLupinSimpleApplicationLoggerImpl implementation logs to the path: SERVERHOME/logs/server/local/firstSampleApplication/run/running_log. In case of the JLupinSimpleApplicationLoggerImpl implementation, the logging level is set in the JLupinSimpleGlobalServerLoggerImpl.initializeWithLogMode(LogMode.DEBUG); method.

The local server logs to the following file as well. SERVERHOME/logs/server/local/APPLICATIONNAME/run std_out_and_err_during_run_YYYY_MM_DD_HH_MM_SS.VERSION.VERSION.txt. This file contains all information which are logged by the System.out.print and System.out.println methods during the objects' initialization in the application's container. These information are not given to the main start-up console of the global server, apart from start-up loggers.