{"record":{"id":"5eaeb4b6aee108ae","repo":"XTLS/Xray-core","slug":"failed-to-start-logger","errorCode":null,"errorMessage":"failed to start logger","messagePattern":"failed to start logger","errorType":"exception","errorClass":"errors.Error","httpStatus":null,"severity":"error","filePath":"app/log/command/command.go","lineNumber":27,"sourceCode":"\t\"github.com/xtls/xray-core/core\"\n\tgrpc \"google.golang.org/grpc\"\n)\n\ntype LoggerServer struct {\n\tV *core.Instance\n}\n\n// RestartLogger implements LoggerService.\nfunc (s *LoggerServer) RestartLogger(ctx context.Context, request *RestartLoggerRequest) (*RestartLoggerResponse, error) {\n\tlogger := s.V.GetFeature((*log.Instance)(nil))\n\tif logger == nil {\n\t\treturn nil, errors.New(\"unable to get logger instance\")\n\t}\n\tif err := logger.Close(); err != nil {\n\t\treturn nil, errors.New(\"failed to close logger\").Base(err)\n\t}\n\tif err := logger.Start(); err != nil {\n\t\treturn nil, errors.New(\"failed to start logger\").Base(err)\n\t}\n\treturn &RestartLoggerResponse{}, nil\n}\n\nfunc (s *LoggerServer) mustEmbedUnimplementedLoggerServiceServer() {}\n\ntype service struct {\n\tv *core.Instance\n}\n\nfunc (s *service) Register(server *grpc.Server) {\n\tls := &LoggerServer{\n\t\tV: s.v,\n\t}\n\tRegisterLoggerServiceServer(server, ls)\n\n\t// For compatibility purposes\n\tvCoreDesc := LoggerService_ServiceDesc","sourceCodeStart":9,"sourceCodeEnd":45,"githubUrl":"https://github.com/XTLS/Xray-core/blob/7d214f8b094f75322fa3990f8aadad1c912f24f5/app/log/command/command.go#L9-L45","documentation":"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.","triggerScenarios":"RestartLogger called when the configured access/error log path became invalid between startup and restart — deleted directory, changed ownership, unwritable mount.","commonSituations":"Container restarts with ephemeral /var/log; misconfigured log paths that only fail on reopen; concurrent restarts.","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"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Ensure the log directory is writable before issuing the restart:\nif err := os.MkdirAll(filepath.Dir(logPath), 0o755); err != nil {\n    return err\n}","typeGuard":null,"tryCatchPattern":"resp, err := loggerClient.RestartLogger(ctx, req)\nif err != nil && strings.Contains(err.Error(), \"failed to start logger\") {\n    // writer reopen failed: fix the path, then retry the restart once\n}","preventionTips":["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"],"tags":["api","grpc","logging","file-io"],"backgroundTag":null,"analyzedSha":"7d214f8b094f75322fa3990f8aadad1c912f24f5","analyzedAt":"2026-08-15T14:26:24.325Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}