Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ngx.log and print not working in the init phase of stream #221

Closed
ghost opened this issue Dec 4, 2020 · 3 comments
Closed

ngx.log and print not working in the init phase of stream #221

ghost opened this issue Dec 4, 2020 · 3 comments

Comments

@ghost
Copy link

ghost commented Dec 4, 2020

stream{
    error_log /var/log/nginx/stream_error.log debug;
    init_by_lua_block {
        ngx.log(ngx.DEBUG,"I'm here")
    }
    init_worker_by_lua_block {
        print("I'm here")
    }

    server {
        listen 123 udp;
        lua_code_cache off;
        content_by_lua_file /var/www/test/main.lua;
    }
}

openresty/1.19.3.1

no msg output in the error log, but in content_by_lua_file ngx.log and print both working well.

@ghost
Copy link
Author

ghost commented Dec 4, 2020

I'm sure the code block has been executed, I got msg from /var/log/syslog

init_by_lua_block {
    local ffi = require("ffi")
    ffi.cdef[[
        void syslog(int priority, const char *format, ...);
    ]]
    ffi.C.syslog(7, "I'm here")
    ngx.log(ngx.DEBUG,"I'm here")
}

@ghost
Copy link
Author

ghost commented Dec 29, 2020

I have read ngx_stream_lua_ngx_log@ngx_stream_lua_log.c

    r = ngx_stream_lua_get_req(L);

    if (r && r->connection && r->connection->log) {
        log = r->connection->log;
    } else {
        log = ngx_cycle->log;
    }

it looks that all the log from init phase will be written to main log, because no any request at this phase.
bu i think it's unreasonable. each log generated from the stream directive should be written to the specified log file.

@agentzh @dndx @spacewander

@zhuizhuhaomeng zhuizhuhaomeng closed this as not planned Won't fix, can't repro, duplicate, stale Jan 10, 2024
@zhuizhuhaomeng
Copy link
Contributor

I don't think we will fix this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant