Log4net
  1. Log4net
  2. LOG4NET-274

log4net doesn't log when running a .Net 4.0 Windows application built in Release mode

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Blocker Blocker
    • Resolution: Fixed
    • Affects Version/s: 1.2.10
    • Fix Version/s: 1.2.11
    • Component/s: None
    • Labels:
      None
    • Environment:
      Visual Studio 2010, C#, Windows 7

      Description

      I've a .Net 4.0 windows service application that uses log4net.

      Here's my log4net config.
      <log4net>
      <appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender">
      <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value="%date [%thread] %-5level %logger [%property

      {Context}] - %message%newline" />
      </layout>
      </appender>

      <appender name="ColorConsoleAppender" type="log4net.Appender.ColoredConsoleAppender">
      <mapping>
      <level value="ERROR" />
      <foreColor value="Red, HighIntensity" />
      </mapping>
      <mapping>
      <level value="FATAL" />
      <foreColor value="Red, HighIntensity" />
      </mapping>
      <mapping>
      <level value="WARN" />
      <foreColor value="Blue, HighIntensity" />
      </mapping>
      <mapping>
      <level value="INFO" />
      <forecolor value="White, HighIntensity" />
      </mapping>
      <mapping>
      <level value="DEBUG" />
      <forecolor value="Green, HighIntensity" />
      </mapping>
      <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value="%date [%thread] %-5level %logger [%property{Context}

      ] - %message%newline" />
      </layout>
      </appender>

      <appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
      <appendToFile value="true" />
      <datePattern value="yyyyMMdd" />
      <file value="Logs/Server.log" />
      <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value="%date [%thread] %-5level %logger [%property

      {Context}] - %message%newline" />
      </layout>
      <maximumFileSize value="10MB" />
      <rollingStyle value="Composite" />
      <staticLogFileName value="true" />
      </appender>

      <appender name="EventLogAppender" type="log4net.Appender.EventLogAppender">
      <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value="%date [%thread] %-5level %logger [%property{Context}

      ] - %message%newline" />
      </layout>
      </appender>

      <root>
      <level value="ALL" />
      <appender-ref ref="ColorConsoleAppender" />
      <appender-ref ref="RollingFileAppender" />
      </root>

      </log4net>

      Logging works as expected when the service starts up while using the exe that was built in debug mode (log files are created at the right file path), but doesn't work when it is using the exe built in release mode.

      I've even tried using a recompiled log4net dll for .Net 4.0 following the steps mentioned at this blog.. http://tseonet.blogspot.com/2010/07/making-log4net-run-on-net-40.html.
      That didn't work either. I was able to compile and run the service. But the result was the same; no logs when using the exe build in release mode.

      Not sure what's going on. Cannot deploy the application built in debug mode into production.

      Any help is greatly appreciated.

        Activity

        Deepu Thomas Palathara created issue -
        Deepu Thomas Palathara made changes -
        Field Original Value New Value
        Description I've a .Net 4.0 windows service application that uses log4net.

        Here's my log4net config.
        <log4net>
          <appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender">
            <layout type="log4net.Layout.PatternLayout">
              <conversionPattern value="%date [%thread] %-5level %logger [%property{Context}] - %message%newline" />
            </layout>
          </appender>

          <appender name="ColorConsoleAppender" type="log4net.Appender.ColoredConsoleAppender">
            <mapping>
              <level value="ERROR" />
              <foreColor value="Red, HighIntensity" />
            </mapping>
            <mapping>
              <level value="FATAL" />
              <foreColor value="Red, HighIntensity" />
            </mapping>
            <mapping>
              <level value="WARN" />
              <foreColor value="Blue, HighIntensity" />
            </mapping>
            <mapping>
              <level value="INFO" />
              <forecolor value="White, HighIntensity" />
            </mapping>
            <mapping>
              <level value="DEBUG" />
              <forecolor value="Green, HighIntensity" />
            </mapping>
            <layout type="log4net.Layout.PatternLayout">
              <conversionPattern value="%date [%thread] %-5level %logger [%property{Context}] - %message%newline" />
            </layout>
          </appender>

          <appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
            <appendToFile value="true" />
            <datePattern value="yyyyMMdd" />
            <file value="Logs/Server.log" />
            <layout type="log4net.Layout.PatternLayout">
              <conversionPattern value="%date [%thread] %-5level %logger [%property{Context}] - %message%newline" />
            </layout>
            <maximumFileSize value="10MB" />
            <rollingStyle value="Composite" />
            <staticLogFileName value="true" />
          </appender>

          <appender name="EventLogAppender" type="log4net.Appender.EventLogAppender">
            <layout type="log4net.Layout.PatternLayout">
              <conversionPattern value="%date [%thread] %-5level %logger [%property{Context}] - %message%newline" />
            </layout>
          </appender>

          <root>
            <level value="ALL" />
            <appender-ref ref="ColorConsoleAppender" />
            <appender-ref ref="RollingFileAppender" />
          </root>

        </log4net>

        Logging works as expected when the service starts up while using the exe that was built in debug mode (log files are created at the right file path), but doesn't work when it is using the exe built in release mode.

        Not sure what's going on.

        Any help is greatly appreciated.
        I've a .Net 4.0 windows service application that uses log4net.

        Here's my log4net config.
        <log4net>
          <appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender">
            <layout type="log4net.Layout.PatternLayout">
              <conversionPattern value="%date [%thread] %-5level %logger [%property{Context}] - %message%newline" />
            </layout>
          </appender>

          <appender name="ColorConsoleAppender" type="log4net.Appender.ColoredConsoleAppender">
            <mapping>
              <level value="ERROR" />
              <foreColor value="Red, HighIntensity" />
            </mapping>
            <mapping>
              <level value="FATAL" />
              <foreColor value="Red, HighIntensity" />
            </mapping>
            <mapping>
              <level value="WARN" />
              <foreColor value="Blue, HighIntensity" />
            </mapping>
            <mapping>
              <level value="INFO" />
              <forecolor value="White, HighIntensity" />
            </mapping>
            <mapping>
              <level value="DEBUG" />
              <forecolor value="Green, HighIntensity" />
            </mapping>
            <layout type="log4net.Layout.PatternLayout">
              <conversionPattern value="%date [%thread] %-5level %logger [%property{Context}] - %message%newline" />
            </layout>
          </appender>

          <appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
            <appendToFile value="true" />
            <datePattern value="yyyyMMdd" />
            <file value="Logs/Server.log" />
            <layout type="log4net.Layout.PatternLayout">
              <conversionPattern value="%date [%thread] %-5level %logger [%property{Context}] - %message%newline" />
            </layout>
            <maximumFileSize value="10MB" />
            <rollingStyle value="Composite" />
            <staticLogFileName value="true" />
          </appender>

          <appender name="EventLogAppender" type="log4net.Appender.EventLogAppender">
            <layout type="log4net.Layout.PatternLayout">
              <conversionPattern value="%date [%thread] %-5level %logger [%property{Context}] - %message%newline" />
            </layout>
          </appender>

          <root>
            <level value="ALL" />
            <appender-ref ref="ColorConsoleAppender" />
            <appender-ref ref="RollingFileAppender" />
          </root>

        </log4net>

        Logging works as expected when the service starts up while using the exe that was built in debug mode (log files are created at the right file path), but doesn't work when it is using the exe built in release mode.

        Not sure what's going on. Cannot deploy the application built in debug mode into production.

        Any help is greatly appreciated.
        Deepu Thomas Palathara made changes -
        Description I've a .Net 4.0 windows service application that uses log4net.

        Here's my log4net config.
        <log4net>
          <appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender">
            <layout type="log4net.Layout.PatternLayout">
              <conversionPattern value="%date [%thread] %-5level %logger [%property{Context}] - %message%newline" />
            </layout>
          </appender>

          <appender name="ColorConsoleAppender" type="log4net.Appender.ColoredConsoleAppender">
            <mapping>
              <level value="ERROR" />
              <foreColor value="Red, HighIntensity" />
            </mapping>
            <mapping>
              <level value="FATAL" />
              <foreColor value="Red, HighIntensity" />
            </mapping>
            <mapping>
              <level value="WARN" />
              <foreColor value="Blue, HighIntensity" />
            </mapping>
            <mapping>
              <level value="INFO" />
              <forecolor value="White, HighIntensity" />
            </mapping>
            <mapping>
              <level value="DEBUG" />
              <forecolor value="Green, HighIntensity" />
            </mapping>
            <layout type="log4net.Layout.PatternLayout">
              <conversionPattern value="%date [%thread] %-5level %logger [%property{Context}] - %message%newline" />
            </layout>
          </appender>

          <appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
            <appendToFile value="true" />
            <datePattern value="yyyyMMdd" />
            <file value="Logs/Server.log" />
            <layout type="log4net.Layout.PatternLayout">
              <conversionPattern value="%date [%thread] %-5level %logger [%property{Context}] - %message%newline" />
            </layout>
            <maximumFileSize value="10MB" />
            <rollingStyle value="Composite" />
            <staticLogFileName value="true" />
          </appender>

          <appender name="EventLogAppender" type="log4net.Appender.EventLogAppender">
            <layout type="log4net.Layout.PatternLayout">
              <conversionPattern value="%date [%thread] %-5level %logger [%property{Context}] - %message%newline" />
            </layout>
          </appender>

          <root>
            <level value="ALL" />
            <appender-ref ref="ColorConsoleAppender" />
            <appender-ref ref="RollingFileAppender" />
          </root>

        </log4net>

        Logging works as expected when the service starts up while using the exe that was built in debug mode (log files are created at the right file path), but doesn't work when it is using the exe built in release mode.

        Not sure what's going on. Cannot deploy the application built in debug mode into production.

        Any help is greatly appreciated.
        I've a .Net 4.0 windows service application that uses log4net.

        Here's my log4net config.
        <log4net>
          <appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender">
            <layout type="log4net.Layout.PatternLayout">
              <conversionPattern value="%date [%thread] %-5level %logger [%property{Context}] - %message%newline" />
            </layout>
          </appender>

          <appender name="ColorConsoleAppender" type="log4net.Appender.ColoredConsoleAppender">
            <mapping>
              <level value="ERROR" />
              <foreColor value="Red, HighIntensity" />
            </mapping>
            <mapping>
              <level value="FATAL" />
              <foreColor value="Red, HighIntensity" />
            </mapping>
            <mapping>
              <level value="WARN" />
              <foreColor value="Blue, HighIntensity" />
            </mapping>
            <mapping>
              <level value="INFO" />
              <forecolor value="White, HighIntensity" />
            </mapping>
            <mapping>
              <level value="DEBUG" />
              <forecolor value="Green, HighIntensity" />
            </mapping>
            <layout type="log4net.Layout.PatternLayout">
              <conversionPattern value="%date [%thread] %-5level %logger [%property{Context}] - %message%newline" />
            </layout>
          </appender>

          <appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
            <appendToFile value="true" />
            <datePattern value="yyyyMMdd" />
            <file value="Logs/Server.log" />
            <layout type="log4net.Layout.PatternLayout">
              <conversionPattern value="%date [%thread] %-5level %logger [%property{Context}] - %message%newline" />
            </layout>
            <maximumFileSize value="10MB" />
            <rollingStyle value="Composite" />
            <staticLogFileName value="true" />
          </appender>

          <appender name="EventLogAppender" type="log4net.Appender.EventLogAppender">
            <layout type="log4net.Layout.PatternLayout">
              <conversionPattern value="%date [%thread] %-5level %logger [%property{Context}] - %message%newline" />
            </layout>
          </appender>

          <root>
            <level value="ALL" />
            <appender-ref ref="ColorConsoleAppender" />
            <appender-ref ref="RollingFileAppender" />
          </root>

        </log4net>

        Logging works as expected when the service starts up while using the exe that was built in debug mode (log files are created at the right file path), but doesn't work when it is using the exe built in release mode.

        I've even tried using a recompiled log4net dll for .Net 4.0 following the steps mentioned at this blog.. http://tseonet.blogspot.com/2010/07/making-log4net-run-on-net-40.html.
        That didn't work either.

        Not sure what's going on. Cannot deploy the application built in debug mode into production.

        Any help is greatly appreciated.
        Deepu Thomas Palathara made changes -
        Description I've a .Net 4.0 windows service application that uses log4net.

        Here's my log4net config.
        <log4net>
          <appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender">
            <layout type="log4net.Layout.PatternLayout">
              <conversionPattern value="%date [%thread] %-5level %logger [%property{Context}] - %message%newline" />
            </layout>
          </appender>

          <appender name="ColorConsoleAppender" type="log4net.Appender.ColoredConsoleAppender">
            <mapping>
              <level value="ERROR" />
              <foreColor value="Red, HighIntensity" />
            </mapping>
            <mapping>
              <level value="FATAL" />
              <foreColor value="Red, HighIntensity" />
            </mapping>
            <mapping>
              <level value="WARN" />
              <foreColor value="Blue, HighIntensity" />
            </mapping>
            <mapping>
              <level value="INFO" />
              <forecolor value="White, HighIntensity" />
            </mapping>
            <mapping>
              <level value="DEBUG" />
              <forecolor value="Green, HighIntensity" />
            </mapping>
            <layout type="log4net.Layout.PatternLayout">
              <conversionPattern value="%date [%thread] %-5level %logger [%property{Context}] - %message%newline" />
            </layout>
          </appender>

          <appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
            <appendToFile value="true" />
            <datePattern value="yyyyMMdd" />
            <file value="Logs/Server.log" />
            <layout type="log4net.Layout.PatternLayout">
              <conversionPattern value="%date [%thread] %-5level %logger [%property{Context}] - %message%newline" />
            </layout>
            <maximumFileSize value="10MB" />
            <rollingStyle value="Composite" />
            <staticLogFileName value="true" />
          </appender>

          <appender name="EventLogAppender" type="log4net.Appender.EventLogAppender">
            <layout type="log4net.Layout.PatternLayout">
              <conversionPattern value="%date [%thread] %-5level %logger [%property{Context}] - %message%newline" />
            </layout>
          </appender>

          <root>
            <level value="ALL" />
            <appender-ref ref="ColorConsoleAppender" />
            <appender-ref ref="RollingFileAppender" />
          </root>

        </log4net>

        Logging works as expected when the service starts up while using the exe that was built in debug mode (log files are created at the right file path), but doesn't work when it is using the exe built in release mode.

        I've even tried using a recompiled log4net dll for .Net 4.0 following the steps mentioned at this blog.. http://tseonet.blogspot.com/2010/07/making-log4net-run-on-net-40.html.
        That didn't work either.

        Not sure what's going on. Cannot deploy the application built in debug mode into production.

        Any help is greatly appreciated.
        I've a .Net 4.0 windows service application that uses log4net.

        Here's my log4net config.
        <log4net>
          <appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender">
            <layout type="log4net.Layout.PatternLayout">
              <conversionPattern value="%date [%thread] %-5level %logger [%property{Context}] - %message%newline" />
            </layout>
          </appender>

          <appender name="ColorConsoleAppender" type="log4net.Appender.ColoredConsoleAppender">
            <mapping>
              <level value="ERROR" />
              <foreColor value="Red, HighIntensity" />
            </mapping>
            <mapping>
              <level value="FATAL" />
              <foreColor value="Red, HighIntensity" />
            </mapping>
            <mapping>
              <level value="WARN" />
              <foreColor value="Blue, HighIntensity" />
            </mapping>
            <mapping>
              <level value="INFO" />
              <forecolor value="White, HighIntensity" />
            </mapping>
            <mapping>
              <level value="DEBUG" />
              <forecolor value="Green, HighIntensity" />
            </mapping>
            <layout type="log4net.Layout.PatternLayout">
              <conversionPattern value="%date [%thread] %-5level %logger [%property{Context}] - %message%newline" />
            </layout>
          </appender>

          <appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
            <appendToFile value="true" />
            <datePattern value="yyyyMMdd" />
            <file value="Logs/Server.log" />
            <layout type="log4net.Layout.PatternLayout">
              <conversionPattern value="%date [%thread] %-5level %logger [%property{Context}] - %message%newline" />
            </layout>
            <maximumFileSize value="10MB" />
            <rollingStyle value="Composite" />
            <staticLogFileName value="true" />
          </appender>

          <appender name="EventLogAppender" type="log4net.Appender.EventLogAppender">
            <layout type="log4net.Layout.PatternLayout">
              <conversionPattern value="%date [%thread] %-5level %logger [%property{Context}] - %message%newline" />
            </layout>
          </appender>

          <root>
            <level value="ALL" />
            <appender-ref ref="ColorConsoleAppender" />
            <appender-ref ref="RollingFileAppender" />
          </root>

        </log4net>

        Logging works as expected when the service starts up while using the exe that was built in debug mode (log files are created at the right file path), but doesn't work when it is using the exe built in release mode.

        I've even tried using a recompiled log4net dll for .Net 4.0 following the steps mentioned at this blog.. http://tseonet.blogspot.com/2010/07/making-log4net-run-on-net-40.html.
        That didn't work either. I was able to compile and run the service. But the result was the same; no logs when using the exe build in release mode.

        Not sure what's going on. Cannot deploy the application built in debug mode into production.

        Any help is greatly appreciated.
        Stefan Bodewig made changes -
        Fix Version/s 1.2.11 [ 12310980 ]
        Fix Version/s 1.2.10 [ 11128 ]
        Stefan Bodewig made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]

          People

          • Assignee:
            Unassigned
            Reporter:
            Deepu Thomas Palathara
          • Votes:
            1 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development