Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I show jBoss logs via browsers. In Firefox each line of log is ended by a new line (as it should) - IE 8 and 9 shows the entire log as a huge blob and not with new line after each line in the log file. When I open a file with .txt extension, IE and Firefox adds < pre > tag around the content and content is displayed fine. But when the file is .log file, IE simply dumps the content. source looks like :

<HTML><HEAD></HEAD> <BODY>content of the log</BODY></HTML>

Anyone faced this nuisance ?

share|improve this question
    
I have no control how .log files are generated by jBoss, so I can not add <br/> tags. –  Ved Feb 21 '12 at 13:27
add comment

1 Answer

up vote 2 down vote accepted

You have to make sure that your web server is delivering .log files as MIME type text/plain, not as text/html. This way, even IE will handle this not as a malformed HTML file but as a plain text file.

share|improve this answer
    
Thanks @SvenW, Can you tell me how to check that ? I made sure that the registry "Content Type" for .log file is "text-plain" - what else is required ? –  Ved Feb 21 '12 at 14:09
    
+1 The problem is the log file contains only LF. Windows and it's brethern (Internet Explorer included) will not recognize this as an End of Line character without the preceeding CR. IE can be tricked into compliance by setting the MIME type as SvenW points out. –  Chris S Feb 21 '12 at 14:14
    
I am directing to jboss/logs directory that shows a list of log files. On clicking server.log, I intend to show the log file in browser window. Where do I set the MIME type ? –  Ved Feb 21 '12 at 14:27
    
On your web server, whatever one you use to serve the log files (I don't know anything about this Java Web stuff, it might entirely be that JBoss is a web server). –  SvW Feb 21 '12 at 14:33
    
Added the following mime-type to log.war's web.xml <mime-mapping> <extension>log</extension> <mime-type>text/plain</mime-type> </mime-mapping> –  Ved Feb 22 '12 at 8:30
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.