I have a dll, which gets an instance of ILog.
Using this ILog instance, i want to get the directory that the logger is writing to, because I want to create a file with some other info into the same folder.
I tried the following:
var fa = _log.Logger.Repository.GetAppenders().FirstOrDefault(a => a is RollingFileAppender);
For the fileappender, it does not have the fa.File option. The options that it shows me are: .DoAppend(), .Name and .Close()
Any ideas how to get the fa.File value? so that I can derive the directory and create my file in that directory?
Figured it, based on a post here: https://stackoverflow.com/a/1343913/475882
I had to specify the type in <>:
var fa = _log.Logger.Repository.GetAppenders().OfType<RollingFileAppender>().FirstOrDefault();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With