I had a console application that could be multiple instances running at a time. Each instance generates an output file, in a path specified in the command line parameters. I want the console application to create a log file (FileAppender) in the same directory as the output file. This will ensure that multiple instances don't write to the same log file, and the log for an instances is in the same location as the output file. Here is how I create and use my logger (in each class and project)
private static readonly ILog Log =
LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
...
// Inside a method
Log.InfoFormat("Output file ({0}) exists, deleting.", _commandLineOptions.OutputFile);
I was hoping that I could use an approach similar to this question