jjchiw / gelf4net

GELF log4net Appender - graylog2
MIT License
63 stars 59 forks source link

Runtime errors (using JSNLog) #47

Closed petne closed 6 years ago

petne commented 7 years ago

Hi,

I'm having some problems with Gelf4Net. I'm using it with JSNLog in a MVC project targeting 4.5. I have also created a class that extends the GelfUdpAppender to reformat JSNLog messages.

In Gelf4Net.UdpAppender (1.0.0.6) it gives me the following error at runtime with the log4net debugging: log4net:ERROR Could not create Appender [GelfUdpAppender] of type [Gelf4net.Appender.GelfUdpAppender, Gelf4net]. Reported error follows. System.IO.FileNotFoundException: Could not load file or assembly 'Gelf4net' or one of its dependencies. The system cannot find the file specified. File name: 'Gelf4net' at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMarkHandle stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName, ObjectHandleOnStack type) at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName) at System.RuntimeType.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark) at System.Type.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase) at log4net.Util.SystemInfo.GetTypeFromString(Assembly relativeAssembly, String typeName, Boolean throwOnError, Boolean ignoreCase) at log4net.Util.SystemInfo.GetTypeFromString(String typeName, Boolean throwOnError, Boolean ignoreCase) at log4net.Repository.Hierarchy.XmlHierarchyConfigurator.ParseAppender(XmlElement appenderElement)

In Gelf4Net (3.0.0.2) package it gives me:

log4net:ERROR Could not create Appender [GelfUdpAppender] of type [Gelf4net.Appender.GelfUdpAppender, Gelf4net]. Reported error follows. System.InvalidOperationException: An asynchronous operation cannot be started at this time. Asynchronous operations may only be started within an asynchronous handler or module or during certain events in the Page lifecycle. If this exception occurred while executing a Page, ensure that the Page is marked <%@ Page Async="true" %>. This exception may also indicate an attempt to call an "async void" method, which is generally unsupported within ASP.NET request processing. Instead, the asynchronous method should return a Task, and the caller should await it. at System.Web.AspNetSynchronizationContext.OperationStarted() at System.Runtime.CompilerServices.AsyncVoidMethodBuilder.Create() at Gelf4Net.Appender.GelfUdpAppender.ActivateOptions() at log4net.Repository.Hierarchy.XmlHierarchyConfigurator.ParseAppender(XmlElement appenderElement)

In Gelf4Net (3.0.0.1) it worked with the normal appender but when I used my own that extended yours it also gave me an error, similar to the first: log4net:ERROR Could not create Appender [JsnGelfUdpAppender] of type [f.log4net.JsnGelfUdpAppender.JsnGelfUdpAppender, JsnGelfUdpAppender]. Reported error follows. System.TypeLoadException: Could not load type 'Gelf4Net.Appender.GelfUdpAppender' from assembly 'Gelf4Net, Version=3.0.0.1, Culture=neutral, PublicKeyToken=null'. at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMarkHandle stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName, ObjectHandleOnStack type) at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName) at System.RuntimeType.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark) at System.Type.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase) at log4net.Util.SystemInfo.GetTypeFromString(Assembly relativeAssembly, String typeName, Boolean throwOnError, Boolean ignoreCase) at log4net.Util.SystemInfo.GetTypeFromString(String typeName, Boolean throwOnError, Boolean ignoreCase) at log4net.Repository.Hierarchy.XmlHierarchyConfigurator.ParseAppender(XmlElement appenderElement)

In Gelf4net/Gelf4NetAppender v 1.2.11.8 it works both on its own and with my extended class.

Kind regards, Peter

jjchiw commented 7 years ago

I think the first error en version 1.0.0.6 it's because I had a mess deciding the name Gelf4Net, Gelf4net, gelf4net.... so I had the problem with TypeCases in git and windows, renaming Gelf4net, Gelf4Net etc....

Anyway I'll look into the 3.0.0.2, I'll try to reproduce the other 2 exceptions creating a MVC project during the Night (GMT+1) and let you know about, I think the problem was to not fully test the new version that it's netstandard compatible....

jjchiw commented 7 years ago

Hi

I couldn't reproduce the exception, I downloaded the JSNLog Demos and added the JSNLogDemo_Log4Net to the examples solution in the repository....

I add a gif "showing" the dependencies, the log4net configuration and it's working, do you have a working sample of how you get the exception?

gelf4net_issue_47

petne commented 7 years ago

Hi,

I don't have an example code to send you atm unfortunately. I'll be gone on a trip for two weeks. I'll see if I can cook something up when I get back to reproduce the error.

Cheers,