question

Prabs-7622 avatar image
0 Votes"
Prabs-7622 asked Prabs-7622 action

EventLog is not supports in Linux using .Net core 3.1

Hi,
I have an C#.net core 3.1 console application, it supports on Linux platform.
I need to get event log(like event viewer application logs in Windows) information from Linux , but i got runtime error:

Error:
Event Log not supports on Linux platform.

Please find the below code,

         **EventLog log = new EventLog("Application");
         Console.WriteLine("Application event log...");
         for (int index = 0; index < log.Entries.Count; index++)
         {
             EventLogEntry entry = log.Entries[index];
             Console.WriteLine("source " + entry.Source);
             Console.WriteLine("Message " + entry.Message + " " + "Time " +  entry.TimeWritten);
         }**

Please help me on this issue.
How to get event logs from Linux using c#.net?

dotnet-csharpdotnet-runtimedotnet-clidotnet-ad
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

lextm avatar image
1 Vote"
lextm answered cheong00 commented

Windows event logs are Windows only, and there is no direct equivalent on Linux. That's exactly why that API call gives you an exception on Linux. You will have to study what logging mechanism is used by Linux, such as syslog separately.

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Yup. Event log is not something exists on Linux. Most likely you have to fetch log file for individual applications.

0 Votes 0 ·