jjchiw / gelf4net

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

Does not load using log4net 1.2.13.0 #20

Closed robsonj closed 8 years ago

robsonj commented 8 years ago

Gelf4net v2.0.3.1 referenced log4net 1.2.13.0 and worked fine. Gelf4net v2.0.3.7 references log4net 1.2.11.0 and thus will not load against 1.2.13.0

robsonj commented 8 years ago

See commit 38267c8

jjchiw commented 8 years ago

thanks! merged and pushed to nuget

robsonj commented 8 years ago

Thanks!

I just pulled down the new version, but its still strictly depending on log4net 1.2.11 unfortunately. Wonder if there is something in how its being build for nuget.

jjchiw commented 8 years ago

But it's not strictly to 1.2.11 aka 2.0.0 the dependecy is >= 2.0.0 (https://www.nuget.org/packages/Gelf4Net/ ) I'm using it with 1.2.13 aka 2.0.3

robsonj commented 8 years ago

Hmm. If you look at the gelf4net.dll with checkasm, it has a dependency on log4net 1.2.11. Also blows up when running here as we have 1.2.13

jjchiw commented 8 years ago

That's because the project is build using log4net 2.0.0 (1.2.11)

I upgraded the example project SimpleConsoleApplication to use log4net 2.0.3 (1.2.13) and it's working fine....

Can you clone the repo and run the SimpleConsoleApplication...

Do you have a test that I can check to look further.

Thanks

wjdavis5 commented 8 years ago

You can also do this in your app.config:

 <dependentAssembly>
        <assemblyIdentity name="log4net" publicKeyToken="669e0ddf0bb1aa2a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-1.2.11.0" newVersion="1.2.13.0" />
      </dependentAssembly>

which will make it work with whatever version of log4net

patrickgreenwell commented 7 years ago

I'm still seeing this when using the latest package from nuget on a .net45 web application even with a binding redirect thrown in my web.config

patrickgreenwell commented 7 years ago

Also I see that the assembly file version in the Nuget Package is listed as 3.0.0.1 even though the package version is 3.0.0.2

jjchiw commented 7 years ago

But what exactly is the issue besides the versioning...

I know that if you run win a new version of log4net when the application starts gelf4net do not load because it was compiled with another version of log4net but if you include in the app.config the binding redirection, it works fine, isn't it?

<dependentAssembly>
    <assemblyIdentity name="log4net" publicKeyToken="669e0ddf0bb1aa2a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-1.2.11.0" newVersion="1.2.13.0" />
  </dependentAssembly>

gelf4net it's compiled using log4net.2.0.7 https://github.com/jjchiw/gelf4net/blob/master/src/Gelf4net/Gelf4net.csproj#L38

And about the versioning in the code is https://github.com/jjchiw/gelf4net/blob/master/src/Gelf4net/Gelf4net.csproj#L38 3.0.02, I think I messed up a little bit with the versioning that I will fix during the weekend

patrickgreenwell commented 7 years ago

The issue ends up being that because log4net can't resolve it can't actually create the Gelf4net appender and then can't use the appender to do logging. So my logging goes nowhere.

I've tried the assembly redirect but it still wants 1.2.11.0 for some reason, I used reflection to find out what references it wanted according to what's in the nuget Package and they're as follows:

for folder /lib/net45/

References for: Gelf4Net, Version=3.0.0.1, Culture=neutral, PublicKeyToken=null
System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
log4net, Version=1.2.11.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a
System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
System.Numerics, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
System.Xml.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
System.Runtime.Serialization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089

for folder /lib/netstandard1.5/

References for: Gelf4Net, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
System.Runtime, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
System.Resources.ResourceManager, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
System.Collections, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
System.ComponentModel.TypeConverter, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
System.Text.Encoding, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
System.IO, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
System.IO.Compression, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
log4net, Version=2.0.7.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a
System.Net.Primitives, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
System.Net.NameResolution, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
System.Collections.Concurrent, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
System.Threading, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
RabbitMQ.Client, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89e7d7c5feba84ce
System.Net.Http, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
System.Threading.Tasks, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
System.Diagnostics.Debug, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
System.Net.Sockets, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
System.Runtime.Extensions, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed
System.Globalization, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
System.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
System.Threading.Thread, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a

So perhaps something to do with how the nuget package gets built with merging in the net45 version?

hopefully this helps, still not sure why the Binding Redirect isn't working, I've tried them in Web.config, app.config, and by throwing in a Gelf4net.config too.

jjchiw commented 7 years ago

Ok I see log4net, Version=1.2.11.0 I'll try to fix this on thursday.

It's strange that the Binding Redirection is not working.... the SampleApplication is using it....

Anyway I'll try to fix the issue on Thursday or the weekend, I don't have any workaround for this issue only the binding redirect...

Which version of log4net are you using?

patrickgreenwell commented 7 years ago

I'm using 2.0.7

patrickgreenwell commented 7 years ago

I do notice in your sample app you're including the config in the app.config and using .Configure(). I'm using an external file and .ConfigureAndWatch on an external file. I'm wondering if that has something to do with it. Thanks for looking into this 🥇

robsonj commented 7 years ago

I thought you had already merged in a pull request from me to upgrade log4net etc?

Sent from my iPhone

On Mar 14, 2017, at 7:22 PM, jjchiw notifications@github.com wrote:

Ok I see log4net, Version=1.2.11.0 I'll try to fix this on thursday.

It's strange that the Binding Redirection is not working.... the SampleApplication is using it....

Anyway I'll try to fix the issue on Thursday or the weekend, I don't have any workaround for this issue only the binding redirect...

Which version of log4net are you using?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

robsonj commented 7 years ago

This one...

https://github.com/jjchiw/gelf4net/pull/46

Sent from my iPhone

On Mar 15, 2017, at 6:51 PM, Jonathan Robson jonathanmrobson@gmail.com wrote:

I thought you had already merged in a pull request from me to upgrade log4net etc?

Sent from my iPhone

On Mar 14, 2017, at 7:22 PM, jjchiw notifications@github.com wrote:

Ok I see log4net, Version=1.2.11.0 I'll try to fix this on thursday.

It's strange that the Binding Redirection is not working.... the SampleApplication is using it....

Anyway I'll try to fix the issue on Thursday or the weekend, I don't have any workaround for this issue only the binding redirect...

Which version of log4net are you using?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

jjchiw commented 7 years ago

Yes I did merged it but I forgot to push the package :( because I was awaiting to resolve the issue of JSNLog https://github.com/jjchiw/gelf4net/issues/47 but since I can not reproduce it, I'll push the new nuget package today :)

jjchiw commented 7 years ago

It took me almost a week to upload the package with the merge #46 but now we have the log4net versions consolidated..... yay!!

@patrickgreenwell Hope that with the new version gelf4net can be loaded, if you still has the problem, reply me in this issue, and I'll look more

The way that I'm using ConfigureAndWatch in a production project is like this

var rootPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
var log4netPath = Path.Combine(rootPath, "log4net.config");
XmlConfigurator.ConfigureAndWatch(new FileInfo(log4netPath));

It's used in a production project with Nancy, Mono, over OWIN since I start the project as an executable file I run it like this mono project.exe the code above is in the Main method and it works :)