How can I get the log filename in code? (So I can print it to the console)
My log file is define like this in app.config:
<appender name="RollingLogFileAppender"
type="log4net.Appender.RollingFileAppender">
<file value="logfile" />
...
You look at your LogManager.GetAllRepositories. Inside the repositories you look at all the appenders in ILoggerRepository.GetAppenders. If the appender is of type RollingFileAppender you check its File property, or if you preffer you can check the appender by Name.
That being said it is very bad to do something like this in your code. What if the configuration is changed at deployment and the appender you expect is no longer present?
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