nginx 开发第三方模块的时调式日志的方法(终端printf输出日志)
2018-02-06 10:30
555 查看
最近在利用nginx做web后端服务开发,做第三方http模开发,无聊记录一哈操作nginx的方法(日志debug,启动,ngin.conf配置等等)
开启调试日志: 要开启调试日志,首先需要在配置Nginx时打开调试功能,然后编译:
2.修改nginx.conf文件
daemon off; 作用是关闭nginx在后台启动(守护进程的模式)
master_process off; 关闭创建子进程
以上都是设置好了就可以和平时一样启动nginx了,在控制台(终端上)显示你代码中格式printf打印日志的方法,输出变量的值调试代码了。
nginx的启动:
nginx的关闭:
第一种方法:
第二方法:
我的nginx.conf文件
开启调试日志: 要开启调试日志,首先需要在配置Nginx时打开调试功能,然后编译:
./configure --with-debug ...
2.修改nginx.conf文件
daemon off; master_process off;
daemon off; 作用是关闭nginx在后台启动(守护进程的模式)
master_process off; 关闭创建子进程
以上都是设置好了就可以和平时一样启动nginx了,在控制台(终端上)显示你代码中格式printf打印日志的方法,输出变量的值调试代码了。
nginx的启动:
./bin/sbin/nginx
nginx的关闭:
第一种方法:
ps -ef |grep nginx kill -9 进程id
第二方法:
./bin/sbin/nginx -s stop
我的nginx.conf文件
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
daemon off; master_process off;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
#post server
server {
listen 8018;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
access_log logs/post.log main;
location / {
root html;
index index.html index.htm;
}
location /v1
{
if ($request_method = GET )
{
return 403;
}
mytest;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html
{
root html;
}
}
#get service
server {
listen 8017;
server_name localhost;
access_log logs/get.log main;
#access_log off;
location /
{
root html;
index index.html index.htm;
}
location /hello
{
if ($request_method = POST )
{
return 403;
}
mytest;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html
{
root html;
}
}
}
相关文章推荐
- nginx php-fpm 输出php错误日志的配置方法
- nginx php-fpm 输出php错误日志的配置方法
- Nginx模块开发(15)—日志模型
- nginx安装第三方模块的方法
- iOS开发日志输出第三方库
- Nginx模块开发-日志模型
- Django开发中的日志输出的方法
- nginx安装第三方模块的方法
- python实现分析apache和nginx日志文件并输出访客ip列表的方法
- nginx第三方模块echo-nginx-module出错unknown directive “echo”的解决方法
- 通过printf在控制台终端输出带颜色的打印或日志信息
- nginx日志模块及日志定时切割的方法
- nginx安装第三方模块的方法
- 如何在nginx下安装第三方模块的方法
- Nginx 模块开发之日志模块---实时记录http请求信息写入flume
- Android开发中调试日志的输出方法
- nginx模块开发(18)—日志分析
- nginx安装第三方模块的方法
- Python同时向控制台和文件输出日志logging的方法 Python logging模块详解
- Android开发中调试日志的输出方法