Writing to Logs
Your Service also logs messages, and you can direct the messages to the DataSynapse logger.
Java
GridServer uses the Java logger, so any messages logged by using a Java Logger object are written to the Engine or Driver log file. For example:
Logger mylog = Logger.getLogger("com.mycompany.myproduct.MyClass");
The level of logs can be increased on a per-class and package level, to help in isolating issues. For example, you could do the following:
LogManager.getLogManager().getLogger("com.livecluster.admin.servlet.AdminControllerServlet").setLevel(Level.INFO);
Both Drivers and Engines capture stdout and stderr, so typically no changes are required to existing implementations to capture logs.
Additionally, the DataSynapse logger is registered as the Apache Commons Logging default handler. If your implementation uses this interface, your messages are logged automatically. The following is a map of levels to DataSynapse levels:
|
Commons |
DataSynapse |
|
fatal |
Severe |
|
error |
Severe |
|
warn |
Warning |
|
info |
Info |
|
debug |
Fine |
|
trace |
Finer |
The Java Driver log manager can be completely disabled so that all Driver log messages are logged according to your configuration of the Java Logging Framework, rather than according to the Driver properties. For example, if the Driver is a part of a large client application that uses a number of Java libraries whose logs are all managed by the Java Logging Framework configuration, you would disable this so that the Driver logs are managed the same way. There is a Driver property, DSLogUseJavaConfig, that enables this behavior when set to true.
.NET
The .NET System.Diagnostics.Trace facility is used for logging; the DataSynapse logger is simply a Trace listener. The DataSynapse logger captures any messages written to the Trace facility. This includes .NET Services; any trace message written by the Service is logged to the Engine log.
C++
The UtilFactory::log function is the preferred method of logging to the DataSynapse log. You can use it on both the Engine and Driver.
|
Note |
For logging to become effective, it is necessary to instantiate the Driver message server first — for instance, by creating a Service object, or by calling |
R
The included rlogger package contains a log method for logging. For example, the following logging is used in the Pi tutorial included in the SDK:
library("rdriver")
library("rlogger")
...
RDPI <- function(N, K) {
rlogger.log(list("RDPI(", N, ", ", K, ") = ", pi), rlogger.FINE)
PDriver
The PDS script language provides redirection of stdout and stderr to a file, via the stdout and stderr clauses in the execute statement. For example:
execute
stdout="$DSWORKDIR/pijob.$DSTASKID.out"
stderr="$DSWORKDIR/error.$DSTASKID"
".\resources\win64\lib\PdriverPiCalc.exe $seed $iterations"
Writing to the Log directory
The Engine’s log directory is [work directory]/log. You can view files written to this directory with the Log Files feature. You can write log messages to your own files, and view them with the Administration Tool.
The work directory is available as follows:
| • | Java: The system property ds.WorkDir |
| • | .NET: The System.AppDomain.CurrentDomain data value ds.WorkDir |
| • | C++, Command Service: The environment variable ds_WorkDir |
| • | PDriver: The variable $DSWORKDIR |
C++/.NET Native stdout/stderr
Aside from the logging methods described above, it is possible to write native stdout and stderr to files that are managed by the Engine. Enable this with the Logging for Native Streams settings in the Engine Configuration. The log files are created in the Engine instance log directory, typically install-dir/work/machine name-instance/log/*. The file names are engine-stdout-PID.log, engine-stderr-PID.log. The files roll when they exceed the maximum size configured in the Engine Configuration.
This affects only native standard output / standard error for C++ and .NET. Java writes to System.out/err go to the regular invoke log file, as do writes from C++ or .NET that use the documented logging facilities.