| + logger

巧用'|' 和 logger 方便快捷实现日志功能

main.c

#include <stdio.h>
#include <unistd.h>

int main(int argc, char *argv[])
{
        int i = 0;
        while(1)
        {
                printf("hello world %d\n", i++);
                fflush(stdout);
                sleep(1);
        }
        return 0;
}

正常启动时,程序输出打印到标准输出;使用 | logger -t a.out 后 ,程序输出打印到logger日志文件中,可使用logread命令查看。

猜你喜欢

转载自blog.csdn.net/lyndon_li/article/details/81634749