在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):cloudflare/lua-resty-logger-socket开源软件地址(OpenSource Url):https://github.com/cloudflare/lua-resty-logger-socket开源编程语言(OpenSource Language):Perl 74.2%开源软件介绍(OpenSource Introduction):Namelua-resty-logger-socket - nonblocking remote access logging for Nginx Table of ContentsStatusThis library is still experimental and under early development. DescriptionThis lua library is a remote logging module for ngx_lua: http://wiki.nginx.org/HttpLuaModule This is aimed to replace Nginx's standard ngx_http_log_module to push access logs to a remote server via an nonblocking socket. A common remote log server supporting sockets is syslog-ng. This Lua library takes advantage of ngx_lua's cosocket API, which ensures 100% nonblocking behavior. Synopsis lua_package_path "/path/to/lua-resty-logger-socket/lib/?.lua;;";
server {
location / {
log_by_lua '
local logger = require "resty.logger.socket"
if not logger.initted() then
local ok, err = logger.init{
host = 'xxx',
port = 1234,
flush_limit = 1234,
drop_limit = 5678,
}
if not ok then
ngx.log(ngx.ERR, "failed to initialize the logger: ",
err)
return
end
end
-- construct the custom access log message in
-- the Lua variable "msg"
local bytes, err = logger.log(msg)
if err then
ngx.log(ngx.ERR, "failed to log message: ", err)
return
end
';
}
} MethodsThis logger module is designed to be shared inside an Nginx worker process by all the requests. So currently only one remote log server is supported. We may support multiple log server sharding in the future. init
Initialize logger with user configurations. This logger must be initted before use. If you do not initialize the logger, you will get an error. Available user configurations are listed as follows:
initted
Get a boolean value indicating whether this module has been initted (by calling the init method). log
Log a message. By default, the log message will be buffered in the logger module until flush
Flushes any buffered messages out to remote immediately. Usually you do not need to call this manually because flushing happens automatically when the buffer is full. InstallationYou need to compile at least ngx_lua 0.9.0 with your Nginx. You need to configure
the lua_package_path directive to
add the path of your
and then load the library in Lua:
TODO
AuthorsJiale Zhi [email protected], CloudFlare Inc. Yichun Zhang (agentzh) [email protected], CloudFlare Inc. Copyright and LicenseThis module is licensed under the BSD license. Copyright (C) 2013, by Jiale Zhi [email protected], CloudFlare Inc. Copyright (C) 2013, by Yichun Zhang [email protected], CloudFlare Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论