XTLS/Xray-core · warning · errors.Error
failed to initialize error logger
Error message
failed to initialize error logger
What it means
Companion to error 36: initErrorLogger failed during log.Instance startup, wrapped with AtWarning so the instance still runs with error logging disabled. The chained Base error carries the actual writer creation failure.
Solutions
- Inspect the Base error for the exact file operation failure
- Create/chown the log directory so the xray user can write
- Use a writable path or /dev/null for the error log if file logging is unwanted
Defensive patterns
Strategy: validation
Validate before calling
if p := cfg.Log.Error; p != "" && p != "none" {
if err := os.MkdirAll(filepath.Dir(p), 0o755); err != nil { return err }
if f, err := os.OpenFile(p, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0o644); err != nil {
return fmt.Errorf("error log not writable: %w", err)
} else { f.Close() }
} Prevention
- Same path hygiene as access logs: writable dir, correct ownership
- Check startup logs for the AtWarning line to catch silent error-log loss
When it happens
Trigger: The error log path in config cannot be created/opened (bad directory, permissions, invalid path), or the error-log handler failed to initialize.
Common situations: Same file-path class of problems as the access logger: unwritable /var/log in containers, wrong ownership, directory in place of file, read-only rootfs in k8s pods.
Related errors
- failed to initialize access logger
- failed to close logger
- failed to start logger
- Log Mask: ipv4 mask must be divisible by 8 and between 0-32
- unable to create log handler for
AI-assisted analysis of XTLS/Xray-core@7d214f8b09 (2026-08-15).
Data as JSON: /api/errors/f44719ef5ac3b6f6.
Report an issue: GitHub.
Appendix: source
Thrown at app/log/log.go:95
func (*Instance) Type() interface{} {
return (*Instance)(nil)
}
func (g *Instance) startInternal() error {
g.Lock()
defer g.Unlock()
if g.active {
return nil
}
g.active = true
if err := g.initAccessLogger(); err != nil {
return errors.New("failed to initialize access logger").Base(err).AtWarning()
}
if err := g.initErrorLogger(); err != nil {
return errors.New("failed to initialize error logger").Base(err).AtWarning()
}
return nil
}
// Start implements common.Runnable.Start().
func (g *Instance) Start() error {
return g.startInternal()
}
// Handle implements log.Handler.
func (g *Instance) Handle(msg log.Message) {
g.RLock()
defer g.RUnlock()
if !g.active {
return
}View on GitHub (pinned to 7d214f8b09)