1.5 System logs

Using the GetLogs method it returns the list of log messages generated in the period requested, for a specific Cloud Server or for all servers. This method can be used to manage the log information during the normal operation of the virtual server, or to get debugging information following a call to the web service methods.
GetLogs can only be used after you have got past the authentication stage.

You can request the logs of a specific virtual server by indicating its ID as an input parameter, or request the logs for all the virtual servers created, by specifying a null value as serverId.

You can also indicate a time interval, to limit the extraction of the information to a specific time period. You can also omit the start date, end date, or both, to remove some or all time limits.

Parameters

serverId Type: Nullable
System.Int32 nullable value that is the unique identifier (ID) for the server and to which the logs are associated. If serverId == null, the logs for all the servers are extracted.

from Type: Nullable
Nullable System.DateTime type value which represents the lower limit of the log extraction period. If from == null, a lower limit for the period is not set in the log extraction.

to Type: Nullable
Nullable System.DateTime type value which represents the upper limit of the log extraction period.   If from == null, an upper limit for the period is not set in the log extraction.

Return Value
The method returns a WsResultOfArrayOfLog object containing information on the outcome of the processing. The Value property for example contains an array of Log objects. Each Log object contains information on its id, operation name, message, creation date and last update, status, user, server, etc.

In the example below the list of logs relating to operations carried out in the last 7 days on all servers associated with the user has been extracted.
//IWsEndUser.GetLogs Method (c# .NET)
private static List<string> GetLogs(WsEndUserClient client)
{
    List<string> logs = new List<string>();

    try
    {
        //calls the GetLogs method, 
        //getting a WsResultOfArrayOfLog object 
        WsResultOfArrayOfLog result =
            client.GetLogs(null, System.DateTime.Now.AddDays(-7), System.DateTime.Now);

        foreach (Log item in result.Value)
            logs.Add(string.Format("{0} {1} {2} - {3} - server: {4}",
                item.LogId,
                item.OperationName,
                item.Message,
                item.Status,
                item.ServerName));
    }
    catch (Exception ex)
    {
        //relaunches the error 
        throw new ApplicationException(ex.Message);
    }

    return logs;
}
//IWsEndUser.GetLogs Method (JAVA)
private static List<String> GetLogs(IWsEndUser client)
{
    List<String> logs = new ArrayList<String>();

    try
    {
        //sets the period using the XMLGregorianCalendar object
        GregorianCalendar cal = new GregorianCalendar();
        DatatypeFactory datatypeFactory = DatatypeFactory.newInstance();
        XMLGregorianCalendar dateTo = datatypeFactory.newXMLGregorianCalendar(cal);
        cal.setTime(new Date());
        cal.add(Calendar.DATE, -7);
        XMLGregorianCalendar dateFrom = datatypeFactory.newXMLGregorianCalendar(cal);

        //calls the Get Logs method, 
        //getting a WsResultOfArrayOfLog object 
        WsResultOfArrayOfLog result =
            client.getLogs(null, dateFrom, dateTo);

        for (Log item : result.getValue().getLog())
        {
            Formatter formatter = new Formatter();
            formatter.format("{%d} {%s} {%s} - {%s} - server: {%s}",
                    item.getLogId(),
                    item.getOperationName(),
                    item.getMessage(),
                    item.getStatus().value(),
                    item.getServerName());
            logs.add(formatter.toString());
        }
    }
    catch (Exception ex)
    {
        //prints the error 
        System.out.println(ex);
    }

    return logs;
}

Version
API: v2.8 URL: https://api.dc1.computing.cloud.it/WsEndUser/v2.8/WsEndUser.svc?wsdl
See also

API: v2.8 URL: https://api.dc1.computing.cloud.it/WsEndUser/v2.8/WsEndUser.svc?wsdl