Skip to content

feat(file-logger): use io.stdout/io.stderr for /dev/stdout and /dev/stderr paths#13681

Open
ecsimsw wants to merge 8 commits into
apache:masterfrom
ecsimsw:file-logger-stdout
Open

feat(file-logger): use io.stdout/io.stderr for /dev/stdout and /dev/stderr paths#13681
ecsimsw wants to merge 8 commits into
apache:masterfrom
ecsimsw:file-logger-stdout

Conversation

@ecsimsw

@ecsimsw ecsimsw commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Description

  • The file-logger plugin uses io.open(path, "a+"), even when path is /dev/stdout or /dev/stderr
  • This depends on OS file permissions, which fails with Permission denied in restricted environments
  • This PR uses io.stdout or io.stderr Lua runtime handles, which are always available regardless of file permissions
  • No schema changes, existing "path": "/dev/stdout" configuration works as before

Changes

  • apisix/plugins/file-logger.lua : use io.stdout/io.stderr handles instead of io.open when path is /dev/stdout or /dev/stderr
  • t/cli/test_file_logger_stdout.sh : add CLI test for stdout output
  • docs/en/latest/plugins/file-logger.md : document /dev/stdout and /dev/stderr in path attribute
  • docs/zh/latest/plugins/file-logger.md : same for Chinese docs

Note on test approach

  • The CLI test runs openresty directly in the foreground instead of using apisix start.
  • Because apisix start launches nginx via io.popen(cmd):read("*all") which consumes the process stdout, making /dev/stdout output unobservable from outside.
  • This is the same approach used in production containers (docker-entrypoint.sh).

Which issue(s) this PR fixes:

Fixes #6797

Checklist

  • I have explained the need for this PR and the problem it solves
  • I have explained the changes or the new features added to this PR
  • I have added tests corresponding to this change
  • I have updated the documentation to reflect this change
  • I have verified that this change is backward compatible

@dosubot dosubot Bot added size:S This PR changes 10-29 lines, ignoring generated files. doc Documentation things enhancement New feature or request labels Jul 9, 2026
@ecsimsw
ecsimsw marked this pull request as draft July 16, 2026 12:51
ecsimsw added 4 commits July 16, 2026 21:54
…cache

std_files is already resolved before open_file_cache is called, so the
branch inside open_file_cache was dead code.
`apisix start` launches nginx via io.popen and consumes its stdout, so it
cannot observe /dev/stdout output. Run openresty in the foreground like the
container entrypoint does, and wait for readiness instead of a fixed sleep.
@ecsimsw
ecsimsw marked this pull request as ready for review July 16, 2026 14:15
@ecsimsw ecsimsw changed the title feat(file-logger): use io.stdout/io.stderr for /dev/stdout and /dev/stderr paths feat(file-logger): use io.stdout/io.stderr for /dev/stdout and /dev/stderr paths Jul 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

doc Documentation things enhancement New feature or request size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: cannot use file-logger to log to stdout

1 participant