0

I've set up log4net to potentially log to three locations: console, rolling file, and a database. I need to be able to turn on and off these three separate locations individually, so I've created a set of loggers, one for each combination. For example...

<logger name="Logfile">
  <level value="ALL" />
  <appender-ref ref="RollingFileAppender" />
</logger>
<logger name="Console">
  <level value="ALL" />
  <appender-ref ref="ConsoleAppender" />
</logger>
<logger name="LogfileConsole">
  <level value="ALL" />
  <appender-ref ref="RollingFileAppender" />
  <appender-ref ref="ConsoleAppender" />
</logger>

My root logging level is set to OFF with no appenders used so that the default is no logging whatsoever. HOWEVER... when I run one of the projects that has logging set to the root, meaning it is turned off, a log file still gets created. The file remains empty and no logging is performed, but if I'm using a logger without the RollingFileAppender in it, why is it creating the log file?

I thought it might be because the root was totally empty, so I made a logger called "None" and set the level to OFF and gave it the ConsoleAppender just for appearances sake, and it still created the file.

It's not interfering with the running of the project or impacting performance, but I'd prefer my log folder not end up cluttered with empty log files for apps that shouldn't be logging. I CANNOT figure out why it's creating a file when the current logger does not use file appender. Help?

AmberWolfe
  • 55
  • 3
  • 8
  • 1
    Try this [Disable Creation of Empty Log File](http://stackoverflow.com/questions/2533403/log4net-how-to-disable-creation-of-empty-log-file-on-app-start) – Eric Scherrer Jan 23 '14 at 18:55
  • Thanks. It's not exactly what I need, but it has a couple ideas I can work with. – AmberWolfe Jan 30 '14 at 20:45

0 Answers0