The easiest and best method for logging events in service code is to use the global Agent logger, rather than the Web services logger. The global Agent logger is best suited for services, handlers, connectors, and transports. This global log file, located at <installdir>/logs/agent.log, is instantiated automatically when the Agent is started.
Section 12.4.1 introduces the global Agent logger. Section 12.4.2 discusses the Web services logger in relation to services.
This section introduces how to use the global Agent logger. For a complete discussion, see Chapter 6, "Logging," in the HydraExpress User Guide.
At Agent start-up, the Agent instantiates a global Agent logger, using it to record significant events related to general Agent processes and service execution. You have access to this logger in HydraExpress server-side code. You can also create your own loggers if you want to log information to locations other than the default log output file.
You can log information from any custom service that you write. In many cases, logging will be functionality added to a service with some other main purpose, but you might also create a service just to log some information.
The default Agent logger is defined in the file <installdir>\conf\loggers.xml.
From within a HydraExpress service, you can access the default Agent logger from the rwsf::LogManager singleton. For example, this code gets the default Agent logger and logs a message:
#include <rwsf/core/LogManager.h> #include <rwsf/core/Logger.h> rwsf::Logger logger = rwsf::LogManager.getLogger(); logger.info("My log message."); |
The Agent logger cannot be used by the client or standalone services. Instead, use the Web services logger, Section 12.3.
Although service code should use the global Agent logger (Section 12.4.1), be aware that the Agent automatically logs some Fatal and Error messages to the Web services logger which may be useful for debugging. This file is located in your <installdir>\logs directory.
Copyright © Rogue Wave Software, Inc. All Rights Reserved.
The Rogue Wave name and logo are registered trademarks of Rogue Wave Software, and HydraExpress is a trademark of Rogue Wave Software. All other trademarks are the property of their respective owners.
Provide feedback to Rogue Wave about its documentation.