EventLog appender C# does not write in event log viewer
Asked Answered
H

0

6

I need to make my C# application to write log in Windows Event viewer.

I Used ,

 <appender name="EventLogAppender" type="log4net.Appender.EventLogAppender" >
  <param name="ApplicationName" value="DataLoader" />
  <layout type="log4net.Layout.PatternLayout">
    <conversionPattern value='{"Processed":"%d{yyyy-MM-dd HH:mm:ss}","Loglevel":"%p","Service":"DataLoader","Instance":"","AdditionalInfo":"%c{1}|%M","logtext":"%m%n"}'/>
  </layout>
</appender>

No Errors in Console but it does not write logs in windows event viewer

Huxley answered 4/7, 2017 at 7:20 Comment(6)
Is that all?Did you define your event sources?Iconoduly
Yes i have defined event source in registryHuxley
public class MyEventSource:EventSource{ void Debug(string formatted, string message, string environment, string member, string path, int line) { WriteEvent(6, formatted, message, environment, member, path, line); } } something like theseIconoduly
I used xml config file for Windows event log writing. we found that the application name does not match with registry sourceHuxley
Changed <param name="ApplicationName" value="Log4net" /> and it was worked. But Still i have doubt that why DataLoader not able to write event log Since i have created Dataloader source in registryHuxley
I tried with some other source name it is working fine. But when i tried with name "DataLoader" It is not workingHuxley

© 2022 - 2024 — McMap. All rights reserved.