XTLS/Xray-core · error · errors.Error
failed to start logger
Error message
failed to start logger
What it means
RestartLogger's final step: after a successful Close it calls logger.Start(); if re-initializing the log writers fails, this error wraps the cause. Start re-runs initAccessLogger/initErrorLogger, so the same file-path problems that break initial startup break the restart.
Source
Thrown at app/log/command/command.go:27
"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{
V: s.v,
}
RegisterLoggerServiceServer(server, ls)
// For compatibility purposes
vCoreDesc := LoggerService_ServiceDescView on GitHub (pinned to 7d214f8b09)
Solutions
- Inspect the Base error for the file create/open failure and fix the path or permissions
- Validate that the log directory exists and is writable before issuing RestartLogger
- If the path is genuinely gone, fix the config and restart the instance rather than the logger
Defensive patterns
Strategy: try-catch
Validate before calling
// Ensure the log directory is writable before issuing the restart:
if err := os.MkdirAll(filepath.Dir(logPath), 0o755); err != nil {
return err
} Try / catch
resp, err := loggerClient.RestartLogger(ctx, req)
if err != nil && strings.Contains(err.Error(), "failed to start logger") {
// writer reopen failed: fix the path, then retry the restart once
} Prevention
- Keep log paths on persistent, writable storage
- Fix path/permission issues before retrying restarts
- If restart keeps failing, restart the full instance after correcting config
When it happens
Trigger: RestartLogger called when the configured access/error log path became invalid between startup and restart — deleted directory, changed ownership, unwritable mount.
Common situations: Container restarts with ephemeral /var/log; misconfigured log paths that only fail on reopen; concurrent restarts.
Related errors
- failed to close logger
- unable to get logger instance
- failed to initialize access logger
- failed to initialize error logger
- unsupported router implementation
AI-assisted analysis of XTLS/Xray-core@7d214f8b09 (2026-08-15).
Data as JSON: /api/errors/5eaeb4b6aee108ae.
Report an issue: GitHub.