Get Log4Net ILog Instance Directory

I have a dll that receives an instance of ILog.

Using this instance of ILog, I want to get the directory that the recorder writes, because I want to create a file with some other information in the same folder.

I tried the following:

var fa = _log.Logger.Repository.GetAppenders().FirstOrDefault(a => a is RollingFileAppender);

For fileappender, it does not have the fa.File option. The options that he shows me are: .DoAppend (),. Name and .Close ()

Any ideas on how to get the fa.File value? so that i can get a directory and create a file in that directory?

+4
source share
1 answer

Got it, based on the post here: fooobar.com/questions/118117 / ...

I needed to specify the type in <>:

var fa = _log.Logger.Repository.GetAppenders().OfType<RollingFileAppender>().FirstOrDefault();
+8
source

All Articles