You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2022/04/06 13:31:59 UTC

[GitHub] [apisix] Alasiac opened a new issue, #6797: bug: cannot use file-logger to log to stdout

Alasiac opened a new issue, #6797:
URL: https://github.com/apache/apisix/issues/6797

   ### Current Behavior
   
   When using the file-logger plugin, it is possible to send the logging to stdout by defining /dev/stdout. This in order to use the docker output and relais this in kubernetes to a ELK stack. Though an error is thrown indicating a permission denied for the current user.
   
   ### Expected Behavior
   
   Be able to use /dev/stdout as a destination with the file-logger plugin.
   
   ### Error Logs
   
   failed to open file: /dev/stdout, error info: /dev/stdout: Permission denied while logging request
   
   ### Steps to Reproduce
   
   Run apisix docker with apisix.yaml:
   ```
   routes:
     - uri: /*
       upstream_id: 1
       plugins:
         file-logger:
           path: /dev/stdout
   
   upstreams:
     - id: 1
       nodes:
         "host.docker.internal:3000": 1
       type: roundrobin
   
   plugins:
     - name: file-logger
   #END
   ```
   
   ### Environment
   
   - APISIX Docker version: apache/apisix:2.13.0-alpine
   - Host system: Macbook Pro Intel with docker desktop for mac


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix] fleashiro commented on issue #6797: bug: cannot use file-logger to log to stdout

Posted by "fleashiro (via GitHub)" <gi...@apache.org>.
fleashiro commented on issue #6797:
URL: https://github.com/apache/apisix/issues/6797#issuecomment-1586478143

   Is this issue still in progress? I noticed that the pr https://github.com/apache/apisix/pull/8681 has been closed. @e1ijah1 @spacewander 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix] spacewander commented on issue #6797: bug: cannot use file-logger to log to stdout

Posted by GitBox <gi...@apache.org>.
spacewander commented on issue #6797:
URL: https://github.com/apache/apisix/issues/6797#issuecomment-1091046582

   Write log to non-regular file is not supported yet.
   There is a plan to support it in the next release.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix] spacewander commented on issue #6797: bug: cannot use file-logger to log to stdout

Posted by GitBox <gi...@apache.org>.
spacewander commented on issue #6797:
URL: https://github.com/apache/apisix/issues/6797#issuecomment-1091048788

   We need to add specific logic around `io.open` to handle stdout/stderr, like `io.stderr` or `io.stdout`:
   https://github.com/apache/apisix/blob/fc3a1c9c7403b4517dcbf760329cf9e4d2c5a5af/apisix/plugins/file-logger.lua


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix] e1ijah1 commented on issue #6797: bug: cannot use file-logger to log to stdout

Posted by GitBox <gi...@apache.org>.
e1ijah1 commented on issue #6797:
URL: https://github.com/apache/apisix/issues/6797#issuecomment-1381221175

   Is this issue still available? If so, could you please assign it to me? I'm interested in trying it out.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix] spacewander commented on issue #6797: bug: cannot use file-logger to log to stdout

Posted by "spacewander (via GitHub)" <gi...@apache.org>.
spacewander commented on issue #6797:
URL: https://github.com/apache/apisix/issues/6797#issuecomment-1465453940

   Have you tested the modification in `file-logger.lua`? The fix is like an early version of https://github.com/apache/apisix/pull/8681, which has been proven is not worked. Since there is an ongoing PR for it, let's wait for the author's feedback.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix] ro4i7 commented on issue #6797: bug: cannot use file-logger to log to stdout

Posted by "ro4i7 (via GitHub)" <gi...@apache.org>.
ro4i7 commented on issue #6797:
URL: https://github.com/apache/apisix/issues/6797#issuecomment-1476081065

   > Have you tested the modification in `file-logger.lua`? The fix is like an early version of #8681, which has been proven is not worked. Since there is an ongoing PR for it, let's wait for the author's feedback.
   
   Ok. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix] Alasiac commented on issue #6797: bug: cannot use file-logger to log to stdout

Posted by GitBox <gi...@apache.org>.
Alasiac commented on issue #6797:
URL: https://github.com/apache/apisix/issues/6797#issuecomment-1163135237

   [apisix-file-logger-problem.zip](https://github.com/apache/apisix/files/8958264/apisix-file-logger-problem.zip)
   
   A bit late, but as requested my usecase which results in 
   2022/06/22 13:55:09 [error] 48#48: *2514 [lua] file-logger.lua:117: write_file_data(): failed to open file: /dev/stdout, error info: /dev/stdout: Permission denied while logging request, client: 192.168.32.1,...
   
   Nothing more than the file logger config as stated in the original issue in combination with the docker image of apisix. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix] Chever-John commented on issue #6797: bug: cannot use file-logger to log to stdout

Posted by GitBox <gi...@apache.org>.
Chever-John commented on issue #6797:
URL: https://github.com/apache/apisix/issues/6797#issuecomment-1163291717

   @Alasiac Got it~
   Thanks a lot for these files!!!
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix] Chever-John commented on issue #6797: bug: cannot use file-logger to log to stdout

Posted by GitBox <gi...@apache.org>.
Chever-John commented on issue #6797:
URL: https://github.com/apache/apisix/issues/6797#issuecomment-1381254756

   @e1ijah1 Sure, Please @spacewander .
   
   Best wish:P


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix] Chever-John commented on issue #6797: bug: cannot use file-logger to log to stdout

Posted by GitBox <gi...@apache.org>.
Chever-John commented on issue #6797:
URL: https://github.com/apache/apisix/issues/6797#issuecomment-1097992029

   I am sorry that I am unable to reproduce this issue.
   Can you provide a complete reproduction of the process?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix] abs007 commented on issue #6797: bug: cannot use file-logger to log to stdout

Posted by "abs007 (via GitHub)" <gi...@apache.org>.
abs007 commented on issue #6797:
URL: https://github.com/apache/apisix/issues/6797#issuecomment-1497330952

   Is it possible that permission was denied because apisix wasn't run with root privileges in this case? @spacewander 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix] Chever-John commented on issue #6797: bug: cannot use file-logger to log to stdout

Posted by GitBox <gi...@apache.org>.
Chever-John commented on issue #6797:
URL: https://github.com/apache/apisix/issues/6797#issuecomment-1094164838

   Hi, if possible, could you provide more dockerfile to reproduce your problem more accurately. @Alasiac [Alasiac](https://github.com/Alasiac)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix] Chever-John commented on issue #6797: bug: cannot use file-logger to log to stdout

Posted by GitBox <gi...@apache.org>.
Chever-John commented on issue #6797:
URL: https://github.com/apache/apisix/issues/6797#issuecomment-1091264258

   I think I can cover this issue. 
   Cause I have experience about this issue.
   And the most important is that I want to learn more about docker and APISIX.
   
   Mybe my promise due time is 4.11.
   If over, anyone can continue this issue.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix] spacewander commented on issue #6797: bug: cannot use file-logger to log to stdout

Posted by "spacewander (via GitHub)" <gi...@apache.org>.
spacewander commented on issue #6797:
URL: https://github.com/apache/apisix/issues/6797#issuecomment-1586559244

   I have reviewed the PR #8681. The direction of this PR is correct as far as I know, but there are some issues in the latest review: https://github.com/apache/apisix/pull/8681#pullrequestreview-1336197360


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix] dtotopus commented on issue #6797: bug: cannot use file-logger to log to stdout

Posted by "dtotopus (via GitHub)" <gi...@apache.org>.
dtotopus commented on issue #6797:
URL: https://github.com/apache/apisix/issues/6797#issuecomment-1479936670

   Hm, I'm a bit confused to be honest, because I just tried the following file-logger configuration prior seeing this thread and successfully logged the request ```{
     "include_resp_body": true,
     "path": "/dev/stdout"
   }``` 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix] ro4i7 commented on issue #6797: bug: cannot use file-logger to log to stdout

Posted by "ro4i7 (via GitHub)" <gi...@apache.org>.
ro4i7 commented on issue #6797:
URL: https://github.com/apache/apisix/issues/6797#issuecomment-1465220652

   Hello @spacewander @Alasiac 
   
   if this issue still open, please assign it to me and give feedback on below solution:
   
   To solve this issue, we need to add specific logic around `io.open` to handle `stdout` and `stderr` like `io.stderr` or io.stdout. Currently, writing logs to non-regular files is not supported in the file-logger plugin. However, there is a plan to support it in the next release.
   
   Here are the steps to fix this issue:
   
   1. Modify the `file-logger.lua` plugin file to handle `stdout` and `stderr`:
   ```
   local function open_file(self, conf)
     if not conf.path then
       return nil, "missing 'path'"
     end
   
     if conf.path == "/dev/stdout" then
       return io.stdout
     elseif conf.path == "/dev/stderr" then
       return io.stderr
     else
       local file, err = io.open(conf.path, "a+")
       if not file then
         return nil, "failed to open file: " .. conf.path .. ", error info: " .. tostring(err)
       end
       return file
     end
   end
   ```
   2. Build a custom image of Apisix with the modified `file-logger.lua` file included.
   
   3. Use the custom image to run Apisix.
   
   With these changes, the file-logger plugin should be able to write logs to `stdout` and `stderr`. This will allow us to send the logging to stdout by defining `/dev/stdout` and relay it in Kubernetes to an ELK stack.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org