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

Redirects Logger.Log(a, b, ex) to Logger.LogException(a, b, ex) #305

Merged
2 commits merged into from
Mar 9, 2014
Merged

Redirects Logger.Log(a, b, ex) to Logger.LogException(a, b, ex) #305

2 commits merged into from
Mar 9, 2014

Conversation

alexangas
Copy link
Contributor

Fixes issue #91, for method signatures Log<TArgument>(LogLevel, string, TArgument) where TArgument is of base type Exception, along with related helper methods.

Another candidate for this is Log(LogLevel, string, object) where object is an Exception, and there may also be others. Please let me know if you would like these added.

As this is a behaviour change (although I think this would be viewed as expected) - perhaps a mention should be made in the next release notes? Or even a config option?

@ghost
Copy link

ghost commented Feb 5, 2014

Thanks for the pull request, I'll look into to it next week when I back
from vacation

ghost pushed a commit that referenced this pull request Mar 9, 2014
Redirects Logger.Log(a, b, ex) to Logger.LogException(a, b, ex)
@ghost ghost merged commit 067855e into NLog:master Mar 9, 2014
@ghost ghost added this to the 3.0 milestone Mar 9, 2014
@ghost ghost added the enhancement label Mar 9, 2014
@alexangas alexangas deleted the log-error-with-exception branch March 10, 2014 04:30
@ilya-g
Copy link
Contributor

ilya-g commented Dec 11, 2014

What if I write Log.Info("The exception is: {0}", ex) by intent? Suppose that I want exception to be rendered in LogEvent's message as string, and not stored in Exception property.

I suggest to check message contains format placeholder {0} and redirect to LogException only if this placeholder is missing.

Also, please note that since methods such as Log(Level, message, TArgument) are marked with [StringFormatMethod("message")] attribute, ReSharper will complain, if you specify argument and not specify format placeholder in the message.

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improvement on existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants