How can I get my IIS web server to serve a ".log" file as text and not instead offer me a save/download

62 views Asked by At

I am trying to get my IIS server to treat .log files in a directory the same as it does a .txt file.

The .txt and .info files are displayed as text in a web page (which is what I want to acheive).

The .log file only wants to be "downloaded" or saved.

I have mime types configured like this in the webpage.conf file.

Everything works except the .log file extension.

The "remove" in line 2 here also seems to have no effect. I didn't have that at first, then added it in case there was some previous mapping affecting it.


    <staticContent>
    <remove fileExtension=".log" />
    <mimeMap fileExtension=".in" mimeType="text/html" />
    <mimeMap fileExtension=".log" mimeType="text/plain" />
        <mimeMap fileExtension=".bob" mimeType="text/plain" />
    <mimeMap fileExtension=".info" mimeType="text/html" />
    <mimeMap fileExtension=".index" mimeType="text/html" />
        <mimeMap fileExtension=".config" mimeType="text/html" />
    <mimeMap fileExtension="*" mimeType="application/octet-stream" />
    </staticContent>

All other tagged files present as text/html, unless they are not one of these extensions and are offered for download.

Server is Windows R12

Have tried editing the MIME type in the Web GUI, directly in the .conf file. No improvements.

1

There are 1 answers

1
YurongDai On

I did a basic test and added the mime type <mimeMap fileExtension=".log" mimeType="text/plain" /> in the web.config file in the root directory of the website,

enter image description here

then my IIS web server to serve a ".log" file as text and not instead offer me a save/download.

enter image description here

I suggest you delete the configuration information and reconfigure it, and clear the browser cache.