Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Log4Net Not Logging When Deployed

Tags:

c#

.net

log4net

Using version 1.2.11. Logging works on my dev machine, but won't create the directory or log when deployed.

I tried:

  • giving full directory access to IUSR, Everyone, local users.
  • running the app pool as a local admin account.
  • to use internal debugging as Phil Haack describes here.

Stopped and started the app pool after each change.

Nothing is produced in the output file.

My log4Net config is below. Any thoughts on what to try next?

<?xml version="1.0"?>
<log4net debug="true">
  <appender name="file" type="log4net.Appender.RollingFileAppender">
    <file value="..\Logging\log.txt" />
    <appendToFile value="true" />
    <rollingStyle value="Composite" />
    <datePattern value="yyyyMMdd" />
    <maxSizeRollBackups value="10" />
    <maximumFileSize value="1MB" />
    <threshold value="DEBUG" />
    <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" />
    </layout>
  </appender>
  <appender name="console" type="log4net.Appender.DebugAppender">
    <layout type="log4net.Layout.PatternLayout">
      <param name="ConversionPattern" value="%d [%t] %-5p %c [%x] &lt;%X{auth}&gt; - %m%n" />
    </layout>
  </appender>
  <root>
    <level value="ALL" />
    <appender-ref ref="file" />
    <appender-ref ref="console" />
  </root>
</log4net>
like image 868
Phil Sandler Avatar asked Jun 13 '13 15:06

Phil Sandler


People also ask

Where are log4net logs stored?

The log4net. config file is located in the \Enterprise7\bin\ directory and is the configuration file for the log4net logging application.

Can we use log4net in .NET core?

Yes, you can still use Log4Net to help you output log statements of text files, databases, and other destinations using . NET Core 6 by installing log4net version 2.0. 7 (this version targets . NET Standard) and beyond via NuGet Packages.


1 Answers

If you're using IIS, make sure the correct group has modify access to the Logs folder (usually IIS_USERS).

like image 116
David Klempfner Avatar answered Oct 16 '22 00:10

David Klempfner