Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logging is not generated after upgrading to 3.0 (duplicate of #183) #191

Closed
jayluc2 opened this issue Sep 26, 2024 · 1 comment
Closed
Milestone

Comments

@jayluc2
Copy link

jayluc2 commented Sep 26, 2024

After updating from version 2.0.15 to 3.0.0, our logging isn't being written. I've managed to isolate this to using GlobalContext properties within the file name, although I suspect anywhere properties are used are also a problem. I've boiled our code down to the minimal set needed to reproduce the issue:

Program.cs:

static void Main(string[] args)
{
    log4net.GlobalContext.Properties["mycustomusername"] = "me";
    
    Configuration configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
    FileInfo logfile = new FileInfo(configuration.FilePath);
    XmlConfigurator.ConfigureAndWatch(logfile);

    var _log = log4net.LogManager.GetLogger(typeof(Program));

    long value = 0;
    while (true)
    {
        _log.Debug($"New value is: {value++}");
        Thread.Sleep(1000);
    }
}

App.Config:

  <log4net>
    <appender name="RollingAppender" type="log4net.Appender.RollingFileAppender">
      <file type="log4net.Util.PatternString" value="f:\temp\%property{mycustomusername}TestAppLog.log"/>
      <appendToFile value="true"/>
      <preserveLogFileNameExtension value="true"/>
      <rollingStyle value="Composite"/>
      <datePattern value=".yyyyMMdd"/>
      <maximumFileSize value="1KB"/>
      <countDirection value="1"/>
      <maxSizeRollBackups value="20"/>
      <staticLogFileName value="false"/>
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%date %-5level [%thread] - %message%newline"/>
      </layout>
    </appender>
    <root>
      <level value="DEBUG"/>
      <appender-ref ref="RollingAppender"/>
    </root>
  </log4net>

This message appears in the console window:
log4net:WARN Unable to set property [file] on object [log4net.Appender.RollingFileAppender] using value [f:\temp%property{mycustomusername}TestAppLog.log] (with acceptable conversion types)

@FreeAndNil
Copy link
Contributor

Hi @jayluc2,

thanks for reporting.
This bug was fixed in https://www.nuget.org/packages/log4net/3.0.1-preview.2
We will release the final 3.0.1 tomorrow.

Duplicate of #183
Related to #184, #185, #186, #187, #188

@FreeAndNil FreeAndNil changed the title Logging is not generated after upgrading to 3.0 Logging is not generated after upgrading to 3.0 (duplicate of #183) Sep 26, 2024
@FreeAndNil FreeAndNil added this to the 3.0.1 milestone Sep 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants