1

I'm using NCalc to do mathematical evaluations in a Console application. It keeps spewing tons of information to the console (Specifically when the Evaluate() function is executed). I was unable to find documentation to stop this. For example:

MyApp.exe Information: 0 : Expression added to cache: 18.855520754*45.5445916666667/100
MyApp.exe Information: 0 : Information: 0 : Expression retrieved from cache: 16*10
MyApp.exe Information: 0 : Expression added to cache: 18.855520754*45.5445916666667/100
MyApp.exe Information: 0 : Expression added to cache: 18.855520754*45.5445916666667/100
MyApp.exe Information: 0 : Expression added to cache: 45.5445916666667/6
MyApp.exe Information: 0 : Expression added to cache: 45.5445916666667/6

Where do I define the output verbosity for NCalc? Thanks

Here is what my App.config looks like (I removed appSettings section. Also, The logging section you see here is for Quartz.NET):

<?xml version="1.0" encoding="utf-8"?>
<configuration>

  <configSections>
    <sectionGroup name="common">
      <section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging" />
    </sectionGroup>
  </configSections>
  <common>
    <logging>
      <!--Used by Quartz-->
      <factoryAdapter type="Common.Logging.Simple.ConsoleOutLoggerFactoryAdapter, Common.Logging">
        <arg key="level" value="Warn" />
        <!--All / Debug / Info / Warn / Error / Fatal / Off-->
        <arg key="showLogName" value="true" />
        <arg key="showDataTime" value="true" />
        <arg key="dateTimeFormat" value="yyyy/MM/dd HH:mm:ss:fff" />
      </factoryAdapter>
    </logging>
  </common>



  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
  </startup>

  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-3.1.0.0" newVersion="3.1.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-10.0.0.0" newVersion="10.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Cors" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Owin.Security" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-3.1.0.0" newVersion="3.1.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="StackExchange.Redis.StrongName" publicKeyToken="c219ff1ca8c2ce46" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-1.2.6.0" newVersion="1.2.6.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>

  <system.web>
    <membership defaultProvider="ClientAuthenticationMembershipProvider">
      <providers>
        <add name="ClientAuthenticationMembershipProvider" type="System.Web.ClientServices.Providers.ClientFormsAuthenticationMembershipProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" />
      </providers>
    </membership>
    <roleManager defaultProvider="ClientRoleProvider" enabled="true">
      <providers>
        <add name="ClientRoleProvider" type="System.Web.ClientServices.Providers.ClientRoleProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" cacheTimeout="86400" />
      </providers>
    </roleManager>
  </system.web>


<system.data>
    <DbProviderFactories>
      <remove invariant="MySql.Data.MySqlClient" />
      <add description=".Net Framework Data Provider for MySQL" invariant="MySql.Data.MySqlClient" name="MySQL Data Provider" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.10.6.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
    </DbProviderFactories>
  </system.data></configuration>
adinas
  • 4,150
  • 3
  • 37
  • 47
  • 1) What does your *logging* configuration look like? Did you try *raising* the default logging level to something above Information? 2) Which NCalc package are you using? [This one](https://www.nuget.org/packages/ncalc/) is 7 years old and use's [.NET's own Tracing framework](https://github.com/sheetsync/NCalc/blob/master/Evaluant.Calculator/Expression.cs#L90) at the `Information` level – Panagiotis Kanavos May 21 '18 at 09:29
  • The .NET tracing framework is [described here](https://learn.microsoft.com/en-us/dotnet/framework/debug-trace-profile/tracing-and-instrumenting-applications). You can configure [multiple listeners](https://learn.microsoft.com/en-us/dotnet/framework/debug-trace-profile/how-to-create-and-initialize-trace-listeners) eg, console or file. You can also configure the verbosity per [source or listener](https://learn.microsoft.com/en-us/dotnet/framework/debug-trace-profile/how-to-use-tracesource-and-filters-with-trace-listeners). – Panagiotis Kanavos May 21 '18 at 09:37
  • I'm using "ncalc by sebastienros" from NuGet. Version 1.3.8 I don't think I have any relevant config in App.config for it. So I need to add something in App.Config to make it use "default" logging level? I'm not sure how by looking at the links you added – adinas May 21 '18 at 12:19
  • What's weird to me is that if I do Trace.TraceInformation("some text"); in my own code, it does not show up anywhere. and this is the command being used inside ncalc (I looked at the source code just now) – adinas May 21 '18 at 13:24
  • and what does *your* app.config look like? `Trace.Information` won't write anything unless you tell it to. Which package did you use? What does *that* source code look like? This is a 7 year old, abandoned package that's been repackaged by a lot of people. You'll have to check the actual source code to understand what each person did with the original code – Panagiotis Kanavos May 21 '18 at 13:26
  • BTW you *can* modify the trace configuration at runtime. Perhaps someone did just that. I'd look for a different library though instead of trying to understand how an old library works – Panagiotis Kanavos May 21 '18 at 13:27
  • Okay, I added to the question my App.Config. I saw that indeed it is 7 years old but it seems to work fine and there is no replacement it seems. I think what I have is not a repackaged version (it has 178k downloads according to nuget). I'll check out modifying it at runtime. Thanks – adinas May 21 '18 at 13:52
  • In the end my issue was Owin.Hosting was setting the Trace. https://stackoverflow.com/questions/17948363/tracelistener-in-owin-self-hosting solved it. Thanks for your help Panagiotis Kanavos – adinas May 23 '18 at 08:43

0 Answers0