日志记录:独立应用程序的系统日志?
对于 Linux 中的玩具命令行应用程序,我决定采用 syslog 方式。使用 LOG_PERROR 选项(据我所知,*nixes 中广泛支持该选项),我还可以将日志消息重定向到 stderr,这使得 syslog 几乎非常适合我的使用。
我的问题是我必须 sudo tail -f /var/log/user.log
,并且我找不到一种方法来告诉 syslog 将我的应用程序中的消息输出到单独的日志无需编辑 syslog.conf,这又需要我使用 sudo。对于我来说,要求我的应用程序的用户拥有 sudo 权限以便他们可以查看其日志是不可接受的。
只要我在 stderr 上得到一份副本,似乎就可以了,但似乎仍然有问题。所以,弟兄们,请不要怀疑我:
路过式应用程序使用 syslog 来满足其日志记录需求是否合规?
LOG_PERROR 的支持范围如何广泛?
不,我不想使用日志库。
For a toy commandline application in linux, I decided to go the syslog way. With the LOG_PERROR option (which I understand is widely supported within the *nixes), I can also redirect log messages to stderr, which makes syslog almost perfect for my use.
My problem is that I have to sudo to tail -f /var/log/user.log
, and I cannot find a way to tell syslog to output msgs from my application to a separate log without editing syslog.conf, which again would require me to sudo. It'll be unacceptable for me to require users of my application to have sudo privilegss just so that they can view its logs.
It seems to be okay as long as I'm getting a copy on stderr, but still there seems to be something amiss. So, un-doubt me, brethren:
Is it kosher for drive-by applications to use syslog for their logging needs?
How widely is LOG_PERROR supported?
No, I don't want to use a logging library.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
syslog
并不是真正为普通用户应用程序而设计的。它供系统管理员使用。syslog
isn't really designed for use by normal user applications. It's intended for the system administrator's use.