class GridLogCommandHandler extends GridRestCommandHandlerAdapter {

    @Override public IgniteInternalFuture<GridRestResponse> handleAsync(GridRestRequest req) {
        assert req != null;

        if (req.command() == LOG) {
            if (log.isDebugEnabled())
                log.debug("Handling log REST request: " + req);

            GridRestLogRequest req0 = (GridRestLogRequest)req;

            if (req0.from() < -1 || req0.to() < -1)
                return new GridFinishedFuture<>(new GridRestResponse(GridRestResponse.STATUS_FAILED,
                    "One of the request parameters is invalid [from=" + req0.from() + ", to=" + req0.to() + ']'));

            int from;

            if (req0.from() != -1) {
                if (req0.to() == -1)
                    return new GridFinishedFuture<>(new GridRestResponse(GridRestResponse.STATUS_FAILED,
                        "Request parameter 'to' is not set."));

                from = req0.from();
            }
            else
                from = DEFAULT_FROM;

            int to;

            if (req0.to() != -1) {
                if (req0.from() == -1)
                    return new GridFinishedFuture<>(new GridRestResponse(GridRestResponse.STATUS_FAILED,
                        "Request parameter 'from' is not set."));

                to = req0.to();
            }
            else
                to = DEFAULT_TO;

            if (from >= to)
                return new GridFinishedFuture<>(new GridRestResponse(GridRestResponse.STATUS_FAILED,
                    "Request parameter 'from' must be less than 'to'."));

            File logFile;

            try {
                if (req0.path() != null) {
                    if (log.fileName() != null) {
                        if (!req0.path().equals(log.fileName())) {
                            return new GridFinishedFuture<>(new GridRestResponse(GridRestResponse.STATUS_FAILED,
                                "Request parameter 'path' must contain a path to valid log file."));
                        }
                        else
                            logFile = new File(req0.path());
                    }
                    else if (req0.path().startsWith(ctx.config().getIgniteHome()))
                        logFile = new File(req0.path());
                    else {
                        return new GridFinishedFuture<>(new GridRestResponse(GridRestResponse.STATUS_FAILED,
                            "Request parameter 'path' must contain a path to valid log file."));
                    }
                }
                else if (log.fileName() == null)
                    logFile = new File(ctx.config().getIgniteHome() + "/work/log/ignite.log");
                else
                    logFile = new File(log.fileName());
            }
            catch (InvalidPathException e) {
                return new GridFinishedFuture<>(new GridRestResponse(GridRestResponse.STATUS_FAILED,
                    "Incorrect path to a log file [msg=" + e.getMessage() + ']'));
            }

            try {
                String content = readLog(from, to, logFile);

                return new GridFinishedFuture<>(new GridRestResponse(content));
            }
            catch (IgniteCheckedException e) {
                return new GridFinishedFuture<>(new GridRestResponse(GridRestResponse.STATUS_FAILED, e.getMessage()));
            }
        }

        return new GridFinishedFuture<>();
    }

    public  GridLogCommandHandler(GridKernalContext ctx);

}