Sha256: bf406459a3bf8a044c93d5395b42accaa2fa0c2ff406814207360e657048510c

Contents?: true

Size: 1.49 KB

Versions: 3

Compression:

Stored size: 1.49 KB

Contents

using System;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using NLog;
using NLog.Targets;

namespace RichTextBox2
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

            RichTextBoxTarget target = new RichTextBoxTarget();
            target.Layout = "${date:format=HH\\:MM\\:ss} ${logger} ${message}";
            target.ControlName = "richTextBox1";
            target.FormName = "Form1";
            target.UseDefaultRowColoringRules = false;
            target.WordColoringRules.Add(
                    new RichTextBoxWordColoringRule(
                        "log", // word
                        "White", // font color
                        "Red", // background color
                        FontStyle.Bold | FontStyle.Italic
                        )
                    );

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

            Logger logger = LogManager.GetLogger("Example");
            logger.Trace("trace log message");
            logger.Debug("debug log message");
            logger.Info("info log message");
            logger.Warn("warn log message");
            logger.Error("error log message");
            logger.Fatal("fatal log message");
            logger.Fatal("fatal log message, rather serious");
        }
    }
}

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
nlog-1.0.0.505.20100822 docs/examples/targets/Configuration API/RichTextBox/WordColoring/Form1.cs
nlog-1.0.0.505 docs/examples/targets/Configuration API/RichTextBox/WordColoring/Form1.cs
nlog-1.0.0.505-mswin32 docs/examples/targets/Configuration API/RichTextBox/WordColoring/Form1.cs