简体   繁体   中英

Log4Net Console Appender in C# WPF Application

I have a WPF application, where RollingFileAppender works fine in logging the messages to a log file. However I am trying to retrieve only INFO level logs and display them in a WPF window. I have tried with NotifyAppender, COnsole Appender, none of them works as expected. Can anyone suggest what would be the correct approach for this, where a WPF window or console window will pop up and show the real time INFO logs.

You could use a filter to achieve what you describe:

<appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender">
  <filter type="log4net.Filter.LevelRangeFilter">
    <levelMin value="INFO" />
    <levelMax value="INFO" />
  </filter>
</appender>

This will show only INFO messages in a console window.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM