What's the similar way to write event log when asp.net core app running on linux platform?

Xie Steven 811 Reputation points


My old ASP.NET Webform application use EventLog to write some information into windows event logs.

I know this API is only available in windows platform, so if my asp.net core mvc runs on linux, it will not work.

I want to know if there're some APIs whcih are available on windows and linux. Then, I can wirte event log like the old code logic.


A set of technologies in the .NET Framework for building web applications and XML web services.
4,242 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Bruce (SqlWork.com) 57,966 Reputation points

    There is no common api, this is why asp.net core uses an injected logger.

    The Unix convention is to write to a log file (stdout or path passed as arg) . Typically to folder in /var/log/

    You can also log to system logging (typically /var/log/system.log) by using posix api openlog() and syslog() (use pinvoke from c#)

    As you are probably going to run the asp.net core app with systemctl or systemd depending on Unix/Linux variant, you will want a logging provider that can write to a file.

    Your distribution may also have a log journaling feature. It will have its own api.

    0 comments No comments