0

If I have my class

public class File
{
    public bool Load(string fileName)
    bool returnValue = false;
    if (File.Exists(fileName))
    {
        returnValue = true;
        Logger.Info("File found.");
    }
    else
    {
        Logger.Error("File does not exists.");
    }
    return returnValue;
}

I tried in my main Program.cs

class Program
{
    static void Main(string[] args)
    {
         var appender = new log4net.Appender.MemoryAppender();
         log4net.Config.BasicConfigurator.Configure(appender);
         var logEntries = appender.GetEvents();

         File file = new File();
         string folderPath = @"C:\User\files\";
         string[] files = Directory.GetFiles(folderPath, "*.*", SearchOption.AllDirectories);

         foreach(string oneFile in files)
         {
             file.Load(oneFile);
             Console.WriteLine(logEntries);
         }
         Console.ReadLine();
    }
}

My program does not write any log in the console, any one can explain why ? Maybe I am all wrong. I just don't get it.

Quack_boi
  • 11
  • 7
  • [this should be able to help](https://stackoverflow.com/a/9377002/18584501), it looks like its often an issue with the log4net configuration file where the console is not included as an appender – ExplodatedFaces Jan 25 '23 at 11:36

0 Answers0