Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Log4Net log showing up in console window

I have the opposite problem as most people do with Log4net. I have a basic rolling log appender, I use the INFO, WARN and ERROR levels in my code behind. I have debug turned off in the app.config. It STILL pushes the log data to the console window in addition to the rolling log appender.

How do I stop this behavior? It makes looking at the console window a nightmare.

My config:

<log4net debug="false">
  <appender name="RollingFileAppender"
            type="log4net.Appender.RollingFileAppender">
    <file type="log4net.Util.PatternString"
          value="milliondollars.log"/>
    <lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
    <rollingStyle value="Composite"/>
    <filter type="log4net.Filter.LevelRangeFilter">
      <acceptOnMatch value="true" />
      <levelMin value="INFO" />
      <levelMax value="FATAL" />
    </filter>
    <datePattern value="yyyyMMdd"/>
    <maxSizeRollBackups value="100"/>
    <maximumFileSize value="15MB"/>
    <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value="%date %-5level %logger: %message%newline" />
    </layout>
  </appender>
  <root>
    <level value="ALL" />
    <appender-ref ref="RollingFileAppender" />
  </root>
</log4net>
like image 792
Tom Whitaker Avatar asked Nov 04 '22 21:11

Tom Whitaker


2 Answers

Well, seems like you don't want to give up any more details...

I can think of the folloiwng possible reasons:

  • You have console appender listed either under any <logger> or <root> section
  • You register console appender programmatically
  • You have a logger wrapper, that always runs Console.Write line before logging
like image 139
Alex Aza Avatar answered Nov 14 '22 23:11

Alex Aza


Based on the additional information you provided, there are a couple things I can see. First, you are logging all messages (including DEBUG messages). You just aren't showing log4net debugging information. As for why you are writing to the console window, I would suggest looking at the wrapper for your logger messages. Maybe you are writing to the console there.

Also, walk through the execution of your program in debug mode. See what line is writing to your console.

like image 22
IAmTimCorey Avatar answered Nov 14 '22 23:11

IAmTimCorey