Sha256: 4c14204def87b8ccd018a7f5de9d2908e48ca81a7713b502e7d11422dee44d49

Contents?: true

Size: 871 Bytes

Versions: 3

Compression:

Stored size: 871 Bytes

Contents

using System;

using NLog;
using NLog.Targets;
using NLog.Layouts;

class Example
{
    static void Main(string[] args)
    {
        FileTarget target = new FileTarget();
        target.FileName = "${basedir}/file.csv";

        CsvLayout layout = new CsvLayout();

        layout.Columns.Add(new CsvColumn("time", "${longdate}"));
        layout.Columns.Add(new CsvColumn("message", "${message}"));
        layout.Columns.Add(new CsvColumn("logger", "${logger}"));
        layout.Columns.Add(new CsvColumn("level", "${level}"));

        target.CompiledLayout = layout;

        NLog.Config.SimpleConfigurator.ConfigureForTargetLogging(target, LogLevel.Debug);

        Logger logger = LogManager.GetLogger("Example");
        logger.Debug("log message");
        logger.Debug("Message with \"quotes\" and \nnew line characters.");
    }
}

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
nlog-1.0.0.505.20100822 docs/examples/targets/Configuration API/File/CSV/Example.cs
nlog-1.0.0.505 docs/examples/targets/Configuration API/File/CSV/Example.cs
nlog-1.0.0.505-mswin32 docs/examples/targets/Configuration API/File/CSV/Example.cs