XTLS/Xray-core · warning · errors.Error
unable to get logger instance
Error message
unable to get logger instance
What it means
Returned by the gRPC LoggerService RestartLogger handler when s.V.GetFeature((*log.Instance)(nil)) yields nil — the running core instance has no log app registered, so there is nothing to restart.
Source
Thrown at app/log/command/command.go:21
import (
"context"
"github.com/xtls/xray-core/app/log"
"github.com/xtls/xray-core/common"
"github.com/xtls/xray-core/common/errors"
"github.com/xtls/xray-core/core"
grpc "google.golang.org/grpc"
)
type LoggerServer struct {
V *core.Instance
}
// RestartLogger implements LoggerService.
func (s *LoggerServer) RestartLogger(ctx context.Context, request *RestartLoggerRequest) (*RestartLoggerResponse, error) {
logger := s.V.GetFeature((*log.Instance)(nil))
if logger == nil {
return nil, errors.New("unable to get logger instance")
}
if err := logger.Close(); err != nil {
return nil, errors.New("failed to close logger").Base(err)
}
if err := logger.Start(); err != nil {
return nil, errors.New("failed to start logger").Base(err)
}
return &RestartLoggerResponse{}, nil
}
func (s *LoggerServer) mustEmbedUnimplementedLoggerServiceServer() {}
type service struct {
v *core.Instance
}
func (s *service) Register(server *grpc.Server) {
ls := &LoggerServer{View on GitHub (pinned to 7d214f8b09)
Solutions
- Enable the log app in the instance config (a log block with a valid loglevel) before calling RestartLogger
- Have API callers treat this as a benign no-op condition when logging is intentionally disabled
- Verify with a GetStats/log status call that the log feature exists before restarting
Defensive patterns
Strategy: type-guard
Validate before calling
// API clients should first confirm the log feature exists:
// (equivalent server-side check)
if s.V.GetFeature((*log.Instance)(nil)) == nil {
return nil, errors.New("unable to get logger instance")
} Type guard
func hasLogger(v *core.Instance) bool {
return v.GetFeature((*log.Instance)(nil)) != nil
} Try / catch
resp, err := loggerClient.RestartLogger(ctx, &RestartLoggerRequest{})
if err != nil && strings.Contains(err.Error(), "unable to get logger instance") {
// logging disabled on the instance: safe to ignore
} Prevention
- Keep a log block enabled in configs that expose the logger API
- Panels should probe for the feature before calling RestartLogger
When it happens
Trigger: Calling the xray API RestartLogger endpoint on an instance whose log app was never registered (log disabled in config or the app omitted from the build).
Common situations: Setting loglevel to 'none'/removing the log section and still issuing API restarts; third-party panels calling RestartLogger unconditionally against minimal instances.
Related errors
- failed to close logger
- failed to start logger
- unsupported router implementation
- AddRule: config type error
- Unable to locate a fake DNS Engine
AI-assisted analysis of XTLS/Xray-core@7d214f8b09 (2026-08-15).
Data as JSON: /api/errors/03637cf059991cd6.
Report an issue: GitHub.