Multiple log4net files.
-
I have a problem regarding multiple log files. In my project i have a GeneralLog (singleton instance) that is configured from the app.config of the application.
the file where to write the events<--> the lowest level a message must reach in order to get written in the log file<--> a value indicating that every message is appended to the log file<--> the message layout<-->
This works. During the execution I create alot more (dynamically) log files from appenders defined like this:
FileAppender generalLogAppender = new FileAppender(); //Initialize the properties of the appender generalLogAppender.Name = generalLogFileName; generalLogAppender.File = "Log+"+ fileName + ".dat"; generalLogAppender.AppendToFile = true; generalLogAppender.Threshold = Level.Warn; PatternLayout layout2 = new PatternLayout(); layout2.ConversionPattern = "\[%d\] - %m%n"; layout2.ActivateOptions(); generalLogAppender.ActivateOptions(); BasicConfigurator.Configure(generalLogAppender);
The files are created, but nothing is written in them, only in the GeneralLog. I am really confused by this. I checked the net and of course CodeProject and found only static examples of logs, never a mixed case.
I am fighting against the Universe... Reference-Rick Cook
-
I have a problem regarding multiple log files. In my project i have a GeneralLog (singleton instance) that is configured from the app.config of the application.
the file where to write the events<--> the lowest level a message must reach in order to get written in the log file<--> a value indicating that every message is appended to the log file<--> the message layout<-->
This works. During the execution I create alot more (dynamically) log files from appenders defined like this:
FileAppender generalLogAppender = new FileAppender(); //Initialize the properties of the appender generalLogAppender.Name = generalLogFileName; generalLogAppender.File = "Log+"+ fileName + ".dat"; generalLogAppender.AppendToFile = true; generalLogAppender.Threshold = Level.Warn; PatternLayout layout2 = new PatternLayout(); layout2.ConversionPattern = "\[%d\] - %m%n"; layout2.ActivateOptions(); generalLogAppender.ActivateOptions(); BasicConfigurator.Configure(generalLogAppender);
The files are created, but nothing is written in them, only in the GeneralLog. I am really confused by this. I checked the net and of course CodeProject and found only static examples of logs, never a mixed case.
I am fighting against the Universe... Reference-Rick Cook
Solved.
BasicConfigurator.Configure(generalLogAppender);
had to be called after the appender was attached to the logger.
I am fighting against the Universe... Reference-Rick Cook