Enter CODE:" /> Enter CODE:" /> Enter CODE:"/>

How do I add a comment into an IIS Log file?

245 Views Asked by At

I have a simple html file on an IIS server that asks a user to enter a code:

<form action="educational_page.html" onsubmit="myFunction()">
  Enter CODE: <input type="text" CODEVal="CODEVal">
  <input type="submit" value="Submit">
</form>

<script>
function myFunction() {
  alert("The form was submitted");
}
</script>

I specifically DON'T want to log what they enter, rather, I just want to know that they clicked the submit button.

This can be easily inferred by reviewing the IIS Logs, but the people I will be providing the logs to may not find it that easy.

What would be helpful is if there was a way for me to add a comment into the IIS Log that said something like: "User clicked the 'submit' button." Preferably on the same line the associated line in the log, so they can easily associate the user who clicked.

Is this possible without running code on the server? I've read some posts doing something similar (Writing to a text file on the server) which appeared to require my running code on the server. I'd rather leave the solution as simple as possible, and not server side.

The rest of the page does what I want. (Loading the educational_page.html) I just want to have an easy to parse file that the end user can search for usernames that clicked on the submit button thereby indicating they possibly entered the code.

1

There are 1 best solutions below

1
Deepak-MSFT On

I agree with the suggestion given by Lex Li.

Client-side JS code could not help writing the logs to the Server side. You need to use Server side code in your app to write logs on the Server-side.

Further, you will not be able to edit/modify IIS logs to append some information in it from your app code.

To achieve your requirement, you could try to write Server-side code that could create/write custom logs files and write data to them.

What you are trying to achieve is not possible using JS code and IIS logs.