A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/NLog/NLog/wiki/Installing-targets below:

Installing targets · NLog/NLog Wiki · GitHub

Some targets support installing. Current the following targets support installing

Install all targets used in the config:

LogManager.Configuration.Install(new InstallationContext());

Uninstall all targets used in the config:

LogManager.Configuration.Uninstall(new InstallationContext());
Example install database target
<target xsi:type="Database" name="db"
        connectionStringName="LoggingDatabase">
    <install-command>
        <text>
            <!--
            NOTE: call LogManager.Configuration.Install(new InstallationContext()); 
                  to execute this query.
            -->
            CREATE TABLE ${var:logTableName} (
            Id bigint primary key not null identity(1,1),
            Logged datetime2,
            Level nvarchar(10),
            LogMessage nvarchar(max),
            MessageUid uniqueidentifier,
            MessagePartUid uniqueidentifier,
            MessagePartDataUid uniqueidentifier,
            )
        </text>
        <ignoreFailures>false</ignoreFailures>
    </install-command>
Troubleshooting installation issues

You can enable the installation log by overriding the default output stream in your InstallationContext. For example, to have the installation log printed out to console, you can use:

LogManager.Configuration.Install(new InstallationContext(Console.Out));

You can also redirect the installation log to a string in memory:

var stringWriter = new StringWriter();
LogManager.Configuration.Install(new InstallationContext(stringWriter));
var installationLog = stringWriter.ToString();   // retrieve the installation output

Note that the log output can also be accessed via InstallationContext.LogOutput:

// This is equivalent to the previous example
var installationContext = new InstallationContext(new StringWriter())
LogManager.Configuration.Install(installationContext);
var installationLog = installationContext.LogOutput.ToString();

Except for application critical exceptions (OutOfMemoryException. StackOverflowException and ThreadAbortException), LogManager.Configuration.Install() will not rethrow any other exception, even when NLog is set up to throw exceptions.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4