toddmeinershagen / NLog.SignalR

Custom NLog target for sending logs to a SignalR hub. This release is based on SignalR 2.0.
Apache License 2.0
31 stars 9 forks source link

Adding support for .Net Core 1.0.1+ #3

Closed sabinayakc closed 6 years ago

sabinayakc commented 7 years ago

Hello there! I am having issues using a custom target to log events to a SignalR Hub. I tried working around your code but I didnt have any luck. Any help would be much appreciated. The following are more details on this issue.

2017-01-08 17:47:16.2061 Error Error in Parsing Configuration File. Exception: NLog.NLogConfigurationException: Exception occurred when loading configuration from C:\OSI_TFS\Mini\Web API\Exl.WebApi.Aspen\Exl.WebApi.Aspen\nlog.config System.ArgumentException: Target cannot be found: 'SignalR' at NLog.Config.Factory2.CreateInstance(String name) at NLog.Config.XmlLoggingConfiguration.ParseTargetsElement(NLogXmlElement targetsElement) at NLog.Config.XmlLoggingConfiguration.ParseNLogElement(NLogXmlElement nlogElement, String filePath, Boolean autoReloadDefault) at NLog.Config.XmlLoggingConfiguration.Initialize(XmlReader reader, String fileName, Boolean ignoreErrors)

And in my Nlog.config `

 <target xsi:type="SignalR" name="signalr" layout="${appName}::${message} ${onexception:${exception:format=type,message,method:maxInnerExceptionLevel=5:innerExceptionSeparator=:separator=/}}"/>`
toddmeinershagen commented 7 years ago

@Sabdeth It looks like NLog cannot find our assembly. Your extensions element in the NLog configuration is incorrect. Instead of SignalR.App, should be NLog.SignalR.

<extensions>
 <add assembly="NLog.SignalR"/>
</extensions>

Let me know if that fixes your issue.

sabinayakc commented 7 years ago

@toddmeinershagen I added "Nlog.SignalR" in the extensions node but I am still getting the same error! Target not found!

Assuming "Nlog.SignalR" needs to be referenced by the project I also added the package in my project.json "NLog.Extensions.Logging": "1.0.0-*", "NLog.Config": "4.4.1", "NLog.SignalR": "2.0.0",

But I get the following error image

Thanks for the reply! Appreciate it

toddmeinershagen commented 7 years ago

@Sabdeth Looks like now that you are trying to load the real target it was able to tell that the assembly does not support .NET core 1.0. I will look into what I need to do to support that and get back to you.

toddmeinershagen commented 7 years ago

Actually - @Sabdeth - do you mind sending me a zip file with the solution you are using to validate the changes? I want to use it as a validation for any changes that I make.

sabinayakc commented 7 years ago

Hey @toddmeinershagen , I have created a sample project which I am using at the moment . You can use this to validate. I have commented the line "Nlog.SignalR" in project.json inorder to build the project. Here is the link for the source code! https://github.com/Sabdeth/SignalR.NetCore.Web

Please let me know if I can be of any assistance! Thanks for your support!

sabinayakc commented 7 years ago

@toddmeinershagen Any updates or progress on this? :)

toddmeinershagen commented 7 years ago

@Sabdeth So, I know what needs to be done.

It appears that NLog does have a BETA version of their library available that is upgraded for the .NET core framework.

I would need to upgrade all of the projects and NuGet references in the solution to the .NET core framework and release under BETA. That is easier said than done - I have been very busy. I believe that there is only one library that is referenced in NuGet that is not upgraded as well. That would also need to be upgraded and released.

If you have time and want to submit a pull request, just make sure that all of the tests pass and that the NuGets are updated. If you are having any trouble with the NuGet stuff, I can assist.

Let me know.

304NotModified commented 7 years ago

@toddmeinershagen I have mailed you :)

I would recommend:

toddmeinershagen commented 7 years ago

@304NotModified - From looking at nuget.org, it seems like NLog has not released a fully upgraded project to .NET core outside of beta/pre-release. Until NLog gets closer to release, I think it is wiser to wait as you said in the 3rd bullet point to wait until VS2017 RTM and netstandard 2.0.

Let me know when you guys get closer to an actual release.

304NotModified commented 7 years ago

yes, we need netstandard2.0 or a drop of LogManager.GetCurrentClassLogger() - the latter was down voted

snakefoot commented 6 years ago

Created PR #8

snakefoot commented 6 years ago

NLog.SignalR ver. 4.1.0 has been released: https://www.nuget.org/packages/NLog.SignalR/4.1.0