Does EL Logging have hard dependency to Newtonsoft.Json.dll?

Topics: Logging Application Block
May 30, 2014 at 4:05 PM

Our application uses EL Logging application block. I think Logging application block has a hard dependency on Newtonsoft.Json.dll.

We have a strict rule in our company against any open source library. We have an exception for Microsoft P&P libraries, but we need to eliminate Newtonsoft.Json.dll from our application binaries.

How can I exclude Newtonsoft.Json.dll from EL since we are not doing any JSON format logging?

Thank you,
Jun 1, 2014 at 9:09 PM
Microsoft.Practices.EnterpriseLibrary.Logging.dll has a reference to Newtonsoft.Json.dll (you can see this in the source or in the assembly manifest). However, this assembly is only required if you are using the JsonLogFormatter so it can be excluded from deployments if you are not using the JsonLogFormatter.

In terms of compilation, I did notice that the Newtonsoft assembly was being copied to the output folder by MsBuild (using VS2013). I hadn't added a reference to the assembly and it turns out that MsBuild was finding an older version of the assembly located at C:\Program Files (x86)\Microsoft Visual Studio 12.0\Blend\Newtonsoft.Json.dll (so I assume VS2013 installed that assembly) and copying that file. If something similar is happening to you you could always delete the assembly from your machine since it's against policy ;) ) or create a post build command to delete the file from the output folder. There may be a way to stop MsBuild from copying the file but I'm not sure how to do it.

Randy Levy
Enterprise Library support engineer
Support How-to
Oct 28, 2014 at 6:31 PM
FYI for anyone who comes across this, if you attempt to ILMerge your dlls and include Enterprise Library Logging ILMerge fails because it cannot find Newtonsoft.Json. Even if I include a reference in the project to Newtonsoft.Json and add it to the list of assemblies to merge I still can't get ILMerge to see it.
Dec 5, 2014 at 9:12 PM
You have to include the /lib:"path to newtonsoft.json here" switch for ILMerge to find it.

I had the same issue and this resolved it.