bash 如何将系统日志输出发送到标准输出?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22252476/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to send the syslog output to stdout?
提问by MOHAMED
I m using syslog in myprograme to generate log messages.
我在我的程序中使用 syslog 来生成日志消息。
Is there a way to send the syslog output of my program to stdout ?
有没有办法将我的程序的 syslog 输出发送到 stdout ?
I do not want to use the tail
command to see my program log, I would like to see it directly on the console
不想用tail
命令看我的程序日志,想直接在控制台看
回答by Klas Lindb?ck
To continuously clone file output to a console/shell use the following command in that console/shell:
要将文件输出连续克隆到控制台/shell,请在该控制台/shell 中使用以下命令:
tail -f <logfile> &
-f
makes tail continue printing whatever gets written to the file
-f
使 tail 继续打印写入文件的任何内容
&
puts the process in the background so you can do other stuff in the window. Omit the &
if you want the console to block until you press ctrl+c
.
&
将进程置于后台,以便您可以在窗口中执行其他操作。&
如果您希望控制台阻塞,则省略 ,直到您按下ctrl+c
。
回答by problemPotato
You'll want to edit your /etc/syslog.conf
file.
你会想要编辑你的/etc/syslog.conf
文件。
depending on exactly what facility you're sending to syslogd, you'll need to add a line something like this:
根据您发送到 syslogd 的确切工具,您需要添加如下一行:
<facility>.debug /dev/console
be sure to check out man 5 syslog.conf
for all the details..
请务必查看man 5 syslog.conf
所有详细信息。