Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autoloading of NLog Extensions Question #291

Closed
coolhome opened this issue May 4, 2019 · 5 comments
Closed

Autoloading of NLog Extensions Question #291

coolhome opened this issue May 4, 2019 · 5 comments

Comments

@coolhome
Copy link

coolhome commented May 4, 2019

Type (choose one): Question
NLog version: (e.g. 4.6.3)
NLog.Extensions.Logging version: (e.g. 1.5.0)
NLog.Web.AspNetCore version: (e.g. 4.8.1)
Platform: .Net 4.5 / .NET Core 1 / .NET Core 2

With the support of loading configuration from Microsoft.Extensions.Configuration in 1.5.0 what is the current limitation for auto loading NLog extensions. The readme does not elaborate on why it won't work yet.

@coolhome
Copy link
Author

coolhome commented May 4, 2019

After digging around I discovered that it actually works in 1.5.0!

{
  "NLog": {
    "ThrowConfigExceptions": true,
    "Extensions": [
      {
        "Assembly":  "NLog.Extensions.AzureStorage" 
      }
    ],
    // ...
}

@czd890
Copy link

czd890 commented May 17, 2019

nlog.config convert to json config. extensions is not work.

{
"NLog": {
        "Extensions": {
            "Assembly": "NLog.MailKit"
        },
        "internalLogLevel": "Info",
        "internalLogFile": "./log/nlog-internal.log",
    }
}

./log/nlog-internal.log output

2019-05-17 12:04:46.3607 Info Message Template Auto Format enabled
2019-05-17 12:04:46.5460 Info Adding target NullTarget(Name=blackhole)
2019-05-17 12:04:46.6423 Info Adding target FileTarget(Name=default-log)
2019-05-17 12:04:46.7648 Info Adding target MailTarget(Name=error-email)
2019-05-17 12:04:46.8218 Info Adding target FileTarget(Name=error-log)
2019-05-17 12:04:46.8775 Info Adding target FileTarget(Name=monitor-data)
2019-05-17 12:04:46.9347 Info Adding target FileTarget(Name=raw-receive-data)
2019-05-17 12:04:46.9892 Info Adding target FileTarget(Name=raw-send-data)
2019-05-17 12:04:47.0448 Info Adding target FileTarget(Name=report-state-data)
2019-05-17 12:04:47.1641 Info Found 147 configuration items
2019-05-17 12:05:24.2041 Error MailTarget(Name=error-email): Error sending mail. Exception: System.Net.Mail.SmtpException: The operation has timed out.
at System.Net.Mail.SmtpClient.Send(MailMessage message)
at NLog.Internal.MySmtpClient.NLog.Internal.ISmtpClient.Send(MailMessage msg)
at NLog.Targets.MailTarget.ProcessSingleMailMessage(IList`1 events)

@czd890
Copy link

czd890 commented May 17, 2019

Not work config json

{
"NLog": {
        "Extensions": {
            "Assembly": "NLog.MailKit"
        },
        "internalLogLevel": "Info",
        "internalLogFile": "./log/nlog-internal.log",
    }
}

Is work json config

{
    "NLog": {
        "Extensions": {
            "mailKit": {
                "Assembly": "NLog.MailKit"
            }
        }
    }
}

@snakefoot
Copy link
Contributor

snakefoot commented May 17, 2019

The local alias of the extension can be random (ex "mailkit"). But I like this better:

        "Extensions": {
            "NLog.MailKit": {
                "Assembly": "NLog.MailKit"
            }
        },

Updated the example config in #263

@snakefoot
Copy link
Contributor

snakefoot commented May 17, 2019

Created a wiki-page, instead of having the example json-config in a PR:

https://github.com/NLog/NLog.Extensions.Logging/wiki/Json-NLog-Config

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants