使用log4cplus在C ++ linux中编写html文件的日志 [英] Write logs in html file using log4cplus in C++ linux

查看:424
本文介绍了使用log4cplus在C ++ linux中编写html文件的日志的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在使用Log4cplus在我们的Linux家电产生日志。这些日志目前在运行Web服务器的家用电器上可用。我们还通过Web浏览器显示此日志文件。然而,由于日志文件是文本(即不是html格式),文件没有格式化,很难分别查看每个日志。

We are using Log4cplus to generate logs in our Linux based home appliance. These logs are currently available on the home appliance on which a web server is running. We also show this logfile through a web browser. However since the log file is text (i.e. not in html format), the file is not formatted and it is difficult to view each log separately.

我们想查看这些日志通过web服务器,日志格式为html。 log4j支持html格式的输出日志,但是我们还没有找到一种方法来使用log4cplus生成html格式的日志。这个发布是收集的想法如何这可能是做到这一点使用log4cplus。无论是在log4cplus或后处理,但实时,因为我们正在实时查找日志。

We would like to view these logs through the web server with logs formatted at html. log4j supports output logs in html format, however we have not found a way to generate html formatted logs using log4cplus. This posting is to gather ideas of how this may be possible to do this using log4cplus. Either within log4cplus or post processing but real-time since we are looking for logs in real-time.

推荐答案

aha 可能是一个生成html文件的起点,但为了获得更丰富的格式,你可以使用

aha Could be a starting point to produce an html file, but to get a richer formatting you could probably write some script using awk to html-ize your output.

例如,考虑以下输出文件:

For example, considering the following output file:

2014-07-02 20:52:39 DEBUG className:200 - This is debug message
2014-07-02 20:52:39 DEBUG className:201 - This is debug message2

html表基于三个第一字段:

The following script will produce some valid html table based on the three first fields:

#!/usr/bin/awk -f

BEGIN { print "<table>"; }
      { print "<tr><td>" $1 "<td></td>" $2 "<td></td>" $3  "</td></tr>"    }
END   { print "</table>"  }

只需展开这个。

要获得实时处理,您需要对其进行守护

To get realtime handling, you will need to daemonize it.

这篇关于使用log4cplus在C ++ linux中编写html文件的日志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆