{"record":{"id":"b078e6a9d676b3ef","repo":"flipped-aurora/gin-vue-admin","slug":"error-b078e6","errorCode":null,"errorMessage":"日志文件不存在","messagePattern":"日志文件不存在","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"server/service/system/sys_log_viewer.go","lineNumber":32,"sourceCode":"\t\"strings\"\n\t\"time\"\n\n\t\"github.com/flipped-aurora/gin-vue-admin/server/global\"\n\tsystemReq \"github.com/flipped-aurora/gin-vue-admin/server/model/system/request\"\n\tsystemRes \"github.com/flipped-aurora/gin-vue-admin/server/model/system/response\"\n)\n\nconst (\n\tDefaultLogChunkLines = 500\n\tMaxLogChunkBytes     = 2 * 1024 * 1024\n\tlogReadBlockSize     = 64 * 1024\n)\n\nvar (\n\tErrInvalidLogMonth    = errors.New(\"日志月份格式不正确\")\n\tErrInvalidLogDate     = errors.New(\"日志日期格式不正确\")\n\tErrInvalidLogPath     = errors.New(\"日志文件路径不合法\")\n\tErrLogFileNotFound    = errors.New(\"日志文件不存在\")\n\tErrLogFileUnreadable  = errors.New(\"日志文件不可读取\")\n\tErrLogRootUnavailable = errors.New(\"日志目录不可读取\")\n)\n\ntype LogViewerService struct{}\n\nfunc (s *LogViewerService) ListDates(ctx context.Context, month string) (result systemRes.LogDateList, err error) {\n\tresult = systemRes.LogDateList{Month: month, Dates: make([]systemRes.LogDateItem, 0)}\n\tif err = validateLogMonth(month); err != nil {\n\t\treturn result, err\n\t}\n\n\tlogRoot, exists, err := openConfiguredLogRoot()\n\tif err != nil {\n\t\treturn result, err\n\t}\n\tif !exists {\n\t\treturn result, nil","sourceCodeStart":14,"sourceCodeEnd":50,"githubUrl":"https://github.com/flipped-aurora/gin-vue-admin/blob/3136500ef380842b0eb6c4daa87c3f8a47fcf9e0/server/service/system/sys_log_viewer.go#L14-L50","documentation":"ErrLogFileNotFound is returned when the requested log target does not exist under the configured log root. openValidatedLogFile returns it when the log root directory itself is absent, or when Lstat on the date directory fails with fs.ErrNotExist. It is a clean, typed \"no such log\" signal, distinct from unreadable (permissions) or invalid (malformed) path errors.","triggerScenarios":"ReadContent/ListFiles for a date that has no directory under the configured log root (e.g. a day with no logs); requesting logs before the app has written any; log root misconfigured or deleted after date validation passed.","commonSituations":"Querying logs for today before the first write; pointing GVA log config at a custom path that was cleaned; Docker containers where logs live on an ephemeral or unmounted volume; timezone differences between client and server days.","solutions":["List available dates first via the list-dates API and pick an existing one.","Verify the configured log output directory (GVA_CONFIG log dir) exists on the server and contains the expected date folders.","If logs should exist, check volume mounts / log rotation cleanup that may have deleted old files.","Confirm client and server agree on the day (timezones) — request the server's date."],"exampleFix":"// before\nGET /logViewer/content?date=2025-08-30&path=app.log  // ErrLogFileNotFound (no such date dir)\n// after\nGET /logViewer/dates?month=2025-08  // pick an existing date, then request content","handlingStrategy":"fallback","validationCode":"dates, err := client.ListDates(ctx, month)\nif err != nil { return err }\nif !slices.Contains(dates, date) {\n\treturn fmt.Errorf(\"no logs for %s; available: %v\", date, dates)\n}","typeGuard":null,"tryCatchPattern":"content, err := client.ReadContent(ctx, date, path)\nif err != nil && errors.Is(err, ErrLogFileNotFound) {\n\t// show \"no logs for this day\" in the UI; optionally fall back to the nearest earlier date\n}","preventionTips":["Populate date pickers from the list-dates API, not from client-side calendars.","Ensure the configured log directory exists and is mounted (especially in containers).","Account for log rotation/cleanup windows when offering old dates.","Handle timezone skew between client and server when choosing 'today'."],"tags":["go","filesystem","log-viewer"],"backgroundTag":"log-file-not-found","analyzedSha":"3136500ef380842b0eb6c4daa87c3f8a47fcf9e0","analyzedAt":"2026-08-31T13:50:02.721Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}