Server Logs Access
It is possible to access raw server logs using the TradrAPI SDK. This can be useful for debugging purposes or for monitoring server activity.
Server logs are monitored on all MetaTrader community servers. Should you require access to server logs for your own private server, please contact the TradrAPI team.
Server logs are only available when running MetaTrader 4 or MetaTrader 5 servers.
Retrieving Server Logs
Server logs can be retrieved using the get()
and list()
methods under the admin.log
namespace.
To retrieve a single log, the log id must be known from beforehand, for example:
import { Log } from '@tradrapi/trading-sdk';
const logId = '7696130c-88e8-4429-96aa-077d9e93ed12';
const log: Log = await tradrApi.admin.log.get(logId);
The response will be a Log
object which contains the following properties:
interface Log {
/** The unique identifier of the log */
id: string;
/** The exchange account ID the log belongs to */
exchangeAccountId: number;
/** The log itself */
data: object;
/**
* The datetime at which the log was written
* @format date-time
*/
createdAt: string;
}
Logs can also be listed using the list
method. For example, to list all logs for a specific exchange account:
import { Log, PaginatedResponse } from '@tradrapi/trading-sdk';
const logs: PaginatedResponse<Log> = await tradrApi.admin.log.list({ exchangeAccountId: 1 });
The following parameters can be used to filter the logs:
interface GetLogsDto {
/** Logs to be retrieved starting from this date and time */
startDate: string;
/** Logs to be retrieved up until to this date and time */
endDate: string;
/** Returns only logs which belong to the specified account */
exchangeAccountId?: string;
/** Return only logs which contain this value in the log message */
filter?: string;
/** The format to return the logs in */
format?: 'csv' | 'json';
}