{"record":{"id":"2814d74df5f88341","repo":"hashicorp/nomad","slug":"no-nomad-log-file-defined-2814d7","errorCode":null,"errorMessage":"No nomad log file defined","messagePattern":"No nomad log file defined","errorType":"http","errorClass":null,"httpStatus":400,"severity":"warning","filePath":"nomad/client_agent_endpoint.go","lineNumber":321,"sourceCode":"\n\t// Try to forward request to remote region/server\n\tif args.ServerID != \"\" {\n\t\tserverToFwd, err := a.forwardFor(args.ServerID, region)\n\t\tif err != nil {\n\t\t\thandleStreamResultError(err, new(int64(400)), encoder)\n\t\t\treturn\n\t\t}\n\t\tif serverToFwd != nil {\n\t\t\t//empty args.ServerID to prevent forwarding loop\n\t\t\targs.ServerID = \"\"\n\t\t\ta.forwardMonitorServer(conn, serverToFwd, args, encoder, decoder, \"Agent.MonitorExport\")\n\t\t\treturn\n\t\t}\n\t}\n\n\tnomadLogPath := a.srv.GetConfig().LogFile\n\tif args.OnDisk && nomadLogPath == \"\" {\n\t\thandleStreamResultError(errors.New(\"No nomad log file defined\"), new(int64(400)), encoder)\n\t}\n\t// NodeID was empty, ServerID was equal to this server,  monitor this server\n\tctx, cancel := context.WithCancel(context.Background())\n\tdefer cancel()\n\topts := monitor.MonitorExportOpts{\n\t\tLogger:       a.srv.logger,\n\t\tLogsSince:    args.LogsSince,\n\t\tServiceName:  args.ServiceName,\n\t\tNomadLogPath: nomadLogPath,\n\t\tOnDisk:       args.OnDisk,\n\t\tFollow:       args.Follow,\n\t\tContext:      ctx,\n\t}\n\n\tframes := make(chan *sframer.StreamFrame, 32)\n\terrCh := make(chan error)\n\tvar buf bytes.Buffer\n\tframeSize := 1024","sourceCodeStart":303,"sourceCodeEnd":339,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/client_agent_endpoint.go#L303-L339","documentation":"Agent.MonitorExport with OnDisk=true streams the Nomad server's log file from disk. If a.srv.GetConfig().LogFile is empty — logging to disk was never configured — there is no file to read, so the endpoint emits this 400 stream error.","triggerScenarios":"Calling MonitorExport with OnDisk=true against a server whose config has no log_file set (Nomad is logging only to stdout/stderr), so GetConfig().LogFile returns \"\".","commonSituations":"Default Nomad installs that never set log_file in the server config; operators expecting logs on disk but relying on default stdout logging; running via containers/systemd capturing stdout without file logging enabled.","solutions":["Set log_file in the Nomad server configuration (e.g. log_file = \"/var/log/nomad/nomad.log\") and restart the server.","Call MonitorExport with OnDisk=false to follow in-memory/stdout logs instead of disk files.","Verify the running server actually loaded the log_file config (check the process args/config).","If managed by systemd, consider StdOut/StdErr journal settings or explicitly configure file logging before using OnDisk export."],"exampleFix":"// before: server HCL, no file logging\ntelemetry { ... }\n// after\nlog_file = \"/var/log/nomad/nomad.log\"\nlog_rotate_bytes = 104857600","handlingStrategy":"fallback","validationCode":"// check server config before requesting on-disk logs\nif strings.EqualFold(serverConfig.LogFile, \"\") {\n    // log_file not set: OnDisk export will fail\n}","typeGuard":null,"tryCatchPattern":"err := client.Agent().MonitorExport(ctx, opts, fn)\nif err != nil && strings.Contains(err.Error(), \"No nomad log file defined\") {\n    // fall back to streaming non-disk logs (OnDisk=false)\n}","preventionTips":["Set log_file in server config wherever on-disk log export is expected.","Use OnDisk=false when servers are known to log only to stdout.","Document/verify log_file provisioning in deployment tooling."],"tags":["logging","configuration","monitor","bad-request"],"backgroundTag":"missing-log-file-config","analyzedSha":"482b49bf1aec006f089bcfc7e632d8f6ac303e5e","analyzedAt":"2026-09-04T07:54:14.808Z","contentChangedAt":"2026-09-04T07:54:14.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}