write to IIS log from an ASP.NET application

前端 未结 4 1536
陌清茗
陌清茗 2021-01-04 18:45

I want to have my ASP.NET application write lines to a log somewhere. Does IIS provide any built-in way to log ASP.NET log messages? I was thinking there might be a way to

4条回答
  •  悲&欢浪女
    2021-01-04 19:10

    What I usually do is to use a 3rd-party logging framework and configure the framework through configuration files (i.e. no need to recompile).

    The frameworks I have used are:

    • log4net - Which has a lot of so called "appenders" to write to different targets like Windows Event Log or a database or a log file.
    • NLog - A logging framework that is a bit easier to use than log4net.

    You have to insert the appropriate log function calls in your application to actually trigger a log entry being created.

    Since your question title states that you want to write to the same log (file) as IIS does; I have no idea how to solve this requirement (left alone that I cannot imagine a reason why you would do this)

提交回复
热议问题