How to log to two different files using NLog
<p>I have the following class:</p>

<pre><code>private string name;
private Logger logger;
private LogLevel lvl;
private LoggingConfiguration config;

public Logger(string name, string path, string format, LogLevel lvl)
{
    this.name = name;

    FileTarget fileTarget = new FileTarget();
    fileTarget.FileName = path;
    fileTarget.Layout = format;

    this.lvl = lvl;
    LoggingRule rule = new LoggingRule(name, lvl, fileTarget);

    config = new LoggingConfiguration();
    config.AddTarget(name, fileTarget);
    config.LoggingRules.Add(rule);

    LogManager.Configuration = config;

    logger = LogManager.GetLogger(this.name);
    logger.Trace("test");
 }
</code></pre>

<p>I create two different loggers like this:</p>

<pre><code>Logger("log1", "c:\\test\\log1.txt", ${message}, LogLevel.Debug);
Logger("log2", "c:\\test\\log2.txt", ${message}, LogLevel.Debug);
</code></pre>

<p>Both files are created with the string test. But when I try to log a message with (a class method):</p>

<pre><code>public void Log(string msg)
{
    logger = NLog.LogManager.GetLogger(name);
    //LogManager.Configuration = config;
    //LogManager.Configuration.Reload();
    logger.Log(lvl, msg);
}
</code></pre>

<p>The message is only logged in the second file. What am I doing wrong?</p>