Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
HydraExpress Web Service Development Guide
Rogue Wave web site:  Home Page  |  Main Documentation Page

12.3 Using the Logger

Both the client and server loggers are implemented as message handlers and invoked statically via the rwsf::HandlerManager class. The simplest way to log a message is to invoke the logger with a string and an optional log level describing the severity of the message. By default, the log level of the message will be Info.

Alternatively you can invoke the logger by passing in a rwsf::CallInfo object. By default, a rwsf::CallInfo object is set at the error level. To change the level of a log message, you call the setLogLevel() method. The code below shows this method of using a logger:

Until explicitly set otherwise as outlined in the following sections, the client and server loggers write to the default log file, webservices.log, located in your <installdir>\logs directory.

12.3.1 The Client Logger

There are two ways to use logging in the client:

12.3.2 Configuring the Client Logger

The client logger is configured in the file client-handlers.xml:

The output from this logger is written to the file client.log in the directory where the client is invoked. Note that the level is set at Info, which means all messages are reported.

At startup, the line of code below loads the configuration file and rwsf::HandlerManager is initialized with the logger. Until this is done, log messages are written to the default log file, webservices.log, described in Section 12.3, "Using the Logger."

Finally, for loadConfiguration() to be successful, a static message handler with the logger name from the configuration file must be defined. You accomplish this by placing the macro shown below in the client implementation file at file scope. Note the use of the provided DefaultLogger class to carry out the actual logging.

The above lines code are all generated automatically in the HydraExpress sample clients. With them in place, logging can be performed as described in Section 12.3.

12.3.3 Logging Without Using the Configuration File

You can also do client-side logging without using the configuration file. The advantage of using the configuration file is that you can change the logging level and the output file name at runtime, without having to recompile your code. But, if you prefer, you can simply create a logger and explicitly set it on the HandlerManager.

Using this method, none of the elements described in Section 12.3.2 are required, only the above code. As with the previous setup, logging itself is performed as described in 10.Section 12.3.



Previous fileTop of DocumentContentsIndex pageNext file

© Copyright Rogue Wave Software, Inc. All Rights Reserved. All Rights Reserved. Rogue Wave is a registered trademark of Rogue Wave Software, Inc. in the United States and other countries. HydraExpress is a trademark of Rogue Wave Software, Inc. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.