flipped-aurora/gin-vue-admin · warning

日志文件不存在

Error message

日志文件不存在

What it means

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.

Source

Thrown at server/service/system/sys_log_viewer.go:32

	"strings"
	"time"

	"github.com/flipped-aurora/gin-vue-admin/server/global"
	systemReq "github.com/flipped-aurora/gin-vue-admin/server/model/system/request"
	systemRes "github.com/flipped-aurora/gin-vue-admin/server/model/system/response"
)

const (
	DefaultLogChunkLines = 500
	MaxLogChunkBytes     = 2 * 1024 * 1024
	logReadBlockSize     = 64 * 1024
)

var (
	ErrInvalidLogMonth    = errors.New("日志月份格式不正确")
	ErrInvalidLogDate     = errors.New("日志日期格式不正确")
	ErrInvalidLogPath     = errors.New("日志文件路径不合法")
	ErrLogFileNotFound    = errors.New("日志文件不存在")
	ErrLogFileUnreadable  = errors.New("日志文件不可读取")
	ErrLogRootUnavailable = errors.New("日志目录不可读取")
)

type LogViewerService struct{}

func (s *LogViewerService) ListDates(ctx context.Context, month string) (result systemRes.LogDateList, err error) {
	result = systemRes.LogDateList{Month: month, Dates: make([]systemRes.LogDateItem, 0)}
	if err = validateLogMonth(month); err != nil {
		return result, err
	}

	logRoot, exists, err := openConfiguredLogRoot()
	if err != nil {
		return result, err
	}
	if !exists {
		return result, nil

View on GitHub (pinned to 3136500ef3)

Solutions

  1. List available dates first via the list-dates API and pick an existing one.
  2. Verify the configured log output directory (GVA_CONFIG log dir) exists on the server and contains the expected date folders.
  3. If logs should exist, check volume mounts / log rotation cleanup that may have deleted old files.
  4. Confirm client and server agree on the day (timezones) — request the server's date.

Example fix

// before
GET /logViewer/content?date=2025-08-30&path=app.log  // ErrLogFileNotFound (no such date dir)
// after
GET /logViewer/dates?month=2025-08  // pick an existing date, then request content
Defensive patterns

Strategy: fallback

Validate before calling

dates, err := client.ListDates(ctx, month)
if err != nil { return err }
if !slices.Contains(dates, date) {
	return fmt.Errorf("no logs for %s; available: %v", date, dates)
}

Try / catch

content, err := client.ReadContent(ctx, date, path)
if err != nil && errors.Is(err, ErrLogFileNotFound) {
	// show "no logs for this day" in the UI; optionally fall back to the nearest earlier date
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of flipped-aurora/gin-vue-admin@3136500ef3 (2026-08-31). Data as JSON: /api/errors/b078e6a9d676b3ef. Report an issue: GitHub.