免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 3597 | 回复: 7
打印 上一主题 下一主题

[Web] 请教:nginx日志记录 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2010-03-19 14:33 |只看该作者 |倒序浏览
我的日志格式是这样的:
    log_format  main  '$remote_addr - $remote_user [$time_local]  '
                      '"$request_method $scheme://$host$request_uri $server_protocol" $status $body_bytes_sent '
                      '"$http_referer" "$http_user_agent"';

但是我发现日志中记录的很多内网访问的记录,就是$remote_addr都是192.168.xx.xx这样的记录,因为日志比较大,所以我不想要这部分的记录。
也就是说nginx能否做到根据来源IP来判断是否记录日志呢?像squid的那样?
谢谢!

论坛徽章:
0
2 [报告]
发表于 2010-03-19 14:53 |只看该作者
i don't know how to solve your problem with log files of nginx.as a system administraor.we should save the entire access log and error day within at least one week.

to prevent your log file from being unlimitedly increased.you have to rotate your log file.
these log files are divided by one day or several hours.to do so.you search the Internet to get help.

论坛徽章:
0
3 [报告]
发表于 2010-03-19 14:57 |只看该作者
感谢todayhero 的回复,但是您说的办法不可行。
毕竟都有自己的需求在,这里的日志是需要每天上传并分析的,并且还要备份。
所以不太希望里面出现大量的无用数据,最笨的办法是在上传前先把不要的数据grep -v掉。
但是我还是希望能通过nginx自己的一些机制来处理。
毕竟grep很不效率。
谢谢!

论坛徽章:
0
4 [报告]
发表于 2010-03-19 15:30 |只看该作者
I  see.

your requirement is little particular.ordinary OS can not help you.you thoroughly depend on yourself.i don't find out any helps from the manual of nginx documents.if you have the time.you carefully read its manual.

Can you tell me whether the clients of LAN access the specific directory.if the clients of LAN acces the specific content you can separately log their access log.such as

location /foobar {
access_log /var/log/foobar.log;
}

this example indicted the access log of 'footbar' directory is written to foobar.log

if this feature is not built-in you only use third-party tools or program developed by yourself.

good luck.

论坛徽章:
0
5 [报告]
发表于 2010-03-19 15:33 |只看该作者
楼上的英文好像很好哟。嘿嘿向你学习

论坛徽章:
0
6 [报告]
发表于 2010-03-19 15:49 |只看该作者
回复 5# scyzxp


    thanks for your praise.i am bored to be dead every day.have no alternate but learning english.

论坛徽章:
0
7 [报告]
发表于 2010-03-19 15:58 |只看该作者
location /foobar {
access_log /var/log/foobar.log;
}

perfect !!!
OK!实现分离了,不需要的虽然没有禁止,但是他记录到了另外一个access.log中,这就是我的需要的!
非常感谢todayhero !!
感谢!

论坛徽章:
0
8 [报告]
发表于 2010-03-19 21:45 |只看该作者
回复 6# todayhero


    我想你应该去翻译一些技术手册这样学习更快。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP