I am using NLog with two targets:
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <targets async="true">
    <target name="logfile" xsi:type="File" fileName="my.log"/>
    <target name="console" xsi:type="Console"/>
  </targets>
  <rules>
    <logger name="*" minlevel="Trace" writeTo="logfile"/>
    <logger name="*" minlevel="Info" writeTo="console"/>
  </rules>
</nlog>
Is it possible to log a message only to the "logfile" target, without having the message written to the "console" target as well?
EDIT
To clarify: I want to direct messages from the same class to different loggers at run time (w/o having to change the XML). Something like:
class Program
{
    static Logger _logger = LogManager.GetCurrentClassLogger();
    static void Main(string[] args)
    {
        // Note - _logger.InfoToTarget() does not really exist
        _logger.InfoToTarget("logfile", "This is my very detailed message, possibly with object dumps");
        _logger.InfoToTarget("console", "Short message");
    }
}
I'm aware that this couples my code with the NLlog.config file.
 
     
     
     
    