I read in wikipedia that python logging module was inspired by log4j .In log4j ,there is an HTMLLayout with which one can create the log file as html.Is there any such facility in python logging? Or do anyone know how I can format the log output into an html file ?
Asked
Active
Viewed 8,646 times
2 Answers
3
the python logging module uses a http://docs.python.org/library/logging.html#logging.Formatter to format the output.
You can set your own formatter to output html. (see this other question How can I color Python logging output? for details on how to define a formatter)
3
I would not recommend storing logs as HTML, having logs easily onward processable is a very important and useful feature, and HTML is hard to parse, and it is also verbose - and logs get large fast :-)
However if you really want to you can write your own formatter that will output to HTML - I am not aware of one already in existence - I suspect for the reasons above.

lifeisstillgood
- 3,265
- 2
- 21
- 22
-
6Good point, but can't you output one "plain" log (potentially for automatic parsing or whatever) and another HTML log simultaneously? Verbosity can be addressed by having some sort of arrangement for automatic curtailing. Looking at an HTML file in a browser is a very convenient way of getting a colour log without too much hassle, surely. Red for error, etc. – mike rodent Feb 12 '14 at 13:44
-
1A very good reason to use HTML for logs is if users have to look at them. In our company we have to support offline systems where people have to provide information over the phone. Being able to filter messages (javascript library) and having color-coding in an accessible way makes HTML a good choice. – Pascal Dec 13 '18 at 06:29