Configuring Logging
This section provides information for using logging for the following Solace Messaging APIs:
For information on logging in the Solace Java API, see Configuring Logging in the Solace Java API.
Solace C API
Logging in the Solace C API does not have any external dependencies. These APIs support logging levels in accordance with syslog (RFC 3164). The table below lists the supported log levels.
| Level | Description |
|---|---|
|
Critical |
These log levels are reserved for internal errors and should be a cause for investigation. Contact Solace for log events at this level. |
|
Error |
|
|
Warn |
Indicates an application error (for example, invalid parameters passed in or unsupported use of the APIs). |
|
Notice |
Reserved for unusual events that do not indicate any error, but they are unexpected and might need investigation. |
|
Info |
Typically used for state changes at a high level (for example, connect/disconnect/reconnect). |
|
Debug |
This log level is voluminous and typically requires us to interpret. |
When a log level is set at a given level, all log events with log level less severe than the selected level are filtered out; all log levels equally or more severe are included. For example, if the Error log filter level is selected, only Error and Critical events are included. In contrast, if Info log filter level is selected, Info, Notice, Warn, Error and Critical events are included, and the Debug level is filtered out.
Logging levels and a log event callback or delegate can be set when the APIs are initialized.
To set up a log callback or delegate in the Solace C API, use solClient_log_setCallback(...).
Related Samples
For an example of how to redirect Solace C API generated logs to stdout, see the RedirectLogs sample.
You can see the example in the Logging.java sample file that demonstrates how to work with logs generated by the API.
You can find these examples on Solace Developers.
Solace Messaging API for JavaScript and Node.js
The default log level of the Solace JavaScript API and Solace Node.js API is INFO. If you want to change the log level, use the solace.SolclientFactory.setLogLevel method after calling solace.SolclientFactory.init. The table below lists the supported log levels.
For example:
-
To load the debug variation of the Solace JavaScript API, select the version 10 API profile, and set the log level to
TRACE, add the following to the entry point of your application:<head> <script src="solclient-debug.js"></script> <script type="text/javascript"> var properties = new solace.SolclientFactoryProperties(); properties.profile = solace.SolclientFactoryProfiles.version10; solace.SolclientFactory.init(properties); solace.SolclientFactory.setLogLevel(solace.Loglevel.TRACE); </script> </head> -
To load the debug variation of the Node.js API, select the version 10 API profile, and set the log level to
TRACE, add the following to the entry point of your application:var solace = require('solclientjs').debug; var properties = new solace.SolclientFactoryProfiles(); properties.profile = solace.SolclientFactoryProfiles.version10; solace.SolclientFactory.init(properties); solace.SolclientFactory.setLogLevel(solace.LogLevel.TRACE);For more information about JavaScript and Node.js behavior profiles, see Initializing and Monitoring APIs. For more information about JavaScript and Node.js API variations, see Code and Compile Guidelines.
| Level | Description |
|---|---|
|
Fatal |
These log levels are reserved for internal errors and should be a cause for investigation. Contact Solace for log events at this level. |
|
Error |
|
|
Warn |
Indicates an application error (for example, invalid parameters passed in or unsupported use of the APIs). |
|
Info |
Reserved for unusual events that do not indicate any error, but they are unexpected and might need investigation. |
|
Debug |
Typically used for state changes at a high level (for example, connect/disconnect/reconnect). It is also used for unusual events that do not indicate any error, but they are unexpected and might need investigation. |
|
Trace |
This log level is voluminous and typically requires us to interpret. |
When a log level is set at a given level, all log events with log level less severe than the selected level are filtered out; all log levels equally or more severe are included. For example, if the Error log filter level is selected, only Error and Fatal events are included.