owasp-amass/amass · error
no log file specified
Error message
no log file specified
What it means
NewFileLogger builds a JSON slog.Logger writing to a file. This error is returned when the logfile argument is an empty string, indicating the caller did not select a log file even though the file logger was chosen.
Source
Thrown at internal/tools/log.go:38
)
func WriteLogMessage(l *slog.Logger, message string) error {
record, err := afmt.JSONLogToRecord(message)
if err != nil {
return err
}
ctx := context.Background()
if l.Handler().Enabled(ctx, record.Level) {
return l.Handler().Handle(ctx, record)
}
return errors.New("logger handler is not enabled")
}
func NewFileLogger(dir, logfile string) (*slog.Logger, error) {
if logfile == "" {
return nil, fmt.Errorf("no log file specified")
}
if dir != "" {
if err := os.MkdirAll(dir, 0640); err != nil {
return nil, fmt.Errorf("failed to create the log directory: %v", err)
}
}
f, err := os.OpenFile(filepath.Join(dir, logfile), os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
if err != nil {
return nil, fmt.Errorf("failed to open the log file: %v", err)
}
return slog.New(slog.NewJSONHandler(f, nil)), nil
}
func NewSyslogLogger() (*slog.Logger, error) {
port := os.Getenv("SYSLOG_PORT")View on GitHub (pinned to 79299dce87)
Solutions
- Provide a non-empty logfile name, e.g. NewFileLogger(dir, "amass.log")
- Set the log file path in the config file or pass the corresponding CLI flag
- Verify the variable feeding the logfile argument is populated (print/inspect before the call)
- Fall back to a sensible default filename when logfile is empty at the call site
Example fix
// before
logger, err := tools.NewFileLogger(dir, logfile) // logfile == ""
// after
if logfile == "" {
logfile = "amass.log"
}
logger, err := tools.NewFileLogger(dir, logfile) Defensive patterns
Strategy: validation
Validate before calling
if logfile == "" {
return errors.New("file logging selected but no log file name provided")
} Try / catch
logger, err := tools.NewFileLogger(dir, logfile)
if err != nil && strings.Contains(err.Error(), "no log file specified") {
logger, err = tools.NewFileLogger(dir, "default.log")
} Prevention
- Make the log-file flag required when --log-type=file, failing fast at flag parsing
- Provide a default log file name in the CLI layer
- Validate that env/config keys feeding logfile are non-empty before calling
- Add a unit test asserting NewFileLogger rejects empty names
When it happens
Trigger: Calling NewFileLogger(dir, "") directly, or the CLI/config resolves to file logging (via selectLogger) with an empty log-file setting (e.g. -logfile flag not provided).
Common situations: Configuring the logger type as "file" but forgetting the log file path; an empty environment variable or config key feeding logfile; a refactor that dropped the default log file name.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- zero names provided in the Organization
- missing the organization name
- failed to unmarshal the level text
- failed to provide a valid HTTP method
- logger handler is not enabled
AI-assisted analysis of owasp-amass/amass@79299dce87 (2026-09-06).
Data as JSON: /api/errors/166a48a5cd43b7b4.
Report an issue: GitHub.