Is there a way to get IIS logs online while saving them to log files with c#? I need to create an application to receive the logs of sites defined on iis during creation and send them to another server by a method such as syslog, etc. There are various open source tools for this, but I need to create my own customized application in c# language. Can anyone guide me in this regard?
2 Answers
you need to add fileWatcher and get notify on line added sou you can view log as you want

- 31
- 8
-
As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Dec 16 '22 at 00:35
Never tried to write a syslog sender(forwarder). But I can offer you some thinking.
Firstly, let's see how to send IIS logs by tools. I installed "kiwi syslog server" on the receiver-server(192.168.2.70) side and "SolarWinds EventLog forwarder for windows" on sender-server side.
On the sender-server, I enable ETW event in the IIS logging module and enable IIS-logging in the Event viewer first. (Microsoft-Windows-IIS logging/logs. right click-enable log)
As you can see, after this IIS log will be write into windows event when they are generated.
Then on the "forwarder",add a syslog server with the receiver ip and add a subscription to the IIS logging event.
Finally, we can see the IIS logs in the receiver-server when they are generated in real time.
So if you want to write a sender by yourself. It will be easy if you consume IIS-logging windows event. It can notify your application when logs are generated and bring with full log information.
After that you need to format UDP message and send them to the target IP by port 514.These 2 package may help you with this work.

- 1,401
- 1
- 2
- 8
-
Hi dear friend Your method is a very good method, but because I wanted to implement the log forwarder myself, I first sent the logs to the Windows event logs as you suggested, and then using the following methods and the syslognet library,I implemented a Windows service for forwarding iis logs to solarwinds kiwi. – Mehdi Kiani Dec 17 '22 at 05:39
-
https://stackoverflow.com/questions/20951667/how-to-write-to-kiwi-syslog-server-log-c-sharp – Mehdi Kiani Dec 17 '22 at 05:39
-
https://stackoverflow.com/questions/35413589/accessing-application-and-service-logs-with-c-sharp – Mehdi Kiani Dec 17 '22 at 05:40
-