-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Mail target causes startup exception when using system mail settings #739
Comments
Can you post your config? It's with a wrapper I see? |
|
Can you try without async and without the file target? |
This is the config with the work around? Can you post the other one also? |
I removed the async and file target, same result. The config I posted above is the broken config, here is the workaround config:
|
Thanks! We try to fix this soon. |
Just checking This is conform the specs?https://github.com/nlog/NLog/wiki/Mail-target |
Yeah, it used to work in 3.2.0.0, I just upgraded to 4.0 and it broke. Documentation looks ok and as I understood it, if I set useSystemNetMailSettings="true", then those values are used unless explicitly overriden in the target properties |
OK we will check what has changed since 3.2.0 |
I see this has been changed indeed in 4.0
|
So I agree, this breaking change is unneeded and unwanted. This will be fixed in 4.0.1 |
Thanks for reporting! 👍 |
This is still not fixed in 4.0.1, 4.1 or 4.1.1. Same error, same trace |
I will test this with an unit test. |
I tested it with [Fact]
public void MailTargetInitialize_WithoutSpecifiedSmtpServer_should_not_ThrowsConfigException2()
{
var config = @"<nlog throwExceptions='true' autoReload='true'>
<targets async='true'>
<target name='m1' type='Mail' html='true'
from='mail@mail.com' to='mail@mail.com' useSystemNetMailSettings='true' subject='Portal Error'
body='Time: ${longdate}${newline}Message:${newline}${message}${newline}Exception:${newline}${exception:format=tostring}' />
</targets>
<rules>
<logger name='*' minlevel='Debug' writeTo='m1' />
</rules>
</nlog>";
var configuration = CreateConfigurationFromString(config);
LogManager.Configuration = configuration;
var logger = LogManager.GetCurrentClassLogger();
logger.Debug("test");
}
And it just works. It seems that the update has failed on your site? Are there more projects in your solution with other versions of NLog? |
Woops, found an old version in the server GAC that was causing problems. Looks like it is working correctly |
OK good to hear it has been solved. I was also thinking is a good idea to log the version of NLog to the internal log :) |
Version: 4.0
Making a call to GetCurrentClassLogger with a mail target causes the following exception.
Workaround: Add smtpServer to config for NLog (to same value as the host parameter in the system settings)
The text was updated successfully, but these errors were encountered: