XLCubed is now FluenceXL. The new wiki can be found here: https://help.fluencexl.com/

Difference between revisions of "Logging"

(Microsoft Application Insights)
Line 80: Line 80:
 
   <bindingRedirect oldVersion="0.0.0.0-2.21.0.429" newVersion="2.21.0.429" />
 
   <bindingRedirect oldVersion="0.0.0.0-2.21.0.429" newVersion="2.21.0.429" />
 
  </dependentAssembly>
 
  </dependentAssembly>
 +
 +
[[Category:Logging]]

Revision as of 15:10, 26 June 2023

From XLCubed v10.0.150 it has become possible to capture logs from XLCubed activity.

The logs for Excel and Web are configured using a JSON file called appsettings.json.

  • For the web this is deployed by default in the /XLCubedWeb directory and will log to a file in the Logs sub-directory.
  • For Excel this file should be created in the %appdata%\XLCubed Ltd\XLCubed Excel Edition folder (you can type this address into File Explorer to go to the correct folder)

The log configuration can have different output targets which you can configure as shown below. You will have to restart Excel if you change the configuration.

You can set the minimum logging level to restrict which events are logged. The following levels are available, from noisiest to quietest:

  • Verbose
  • Debug
  • Information (the default)
  • Warning
  • Error
  • Fatal

Sample configurations

File logging

This will log Verbose messages to a file. Note that backslashes in the file path must be doubled.

{
 "Serilog": {
   "MinimumLevel": "Verbose",
   "WriteTo": [
     {
       "Name": "File",
       "Args": {
         "path": "C:\\Path\\To\\Logs\\error.log",
         "rollingInterval": "Day",
         "retainedFileCountLimit": 10,
         "restrictedToMinimumLevel": "Verbose"
       }
     }
   ]
 }
}

System Debug output stream

Alternatively, you can log to the debug output, which you can capture using DebugView a free tool from Microsoft. Note that this will have information from other programs running on the computer, so may be harder to interpret.

{
 "Serilog": {
   "MinimumLevel": "Verbose",
   "WriteTo": [
     { "Name": "Debug" }
   ]
 }
}

Microsoft Application Insights

You can enable Microsoft Application Insights by copying Serilog.Sinks.ApplicationInsights.dll and Microsoft.ApplicationInsights.dll into the installation folder (the bin folder for a web installation) and setting your appsettings.json to load them:

{
 "Serilog": {
   "Using": [
     "Serilog.Sinks.ApplicationInsights"
   ],
   "MinimumLevel": "Verbose",
   "WriteTo": [
     {
       "Name": "ApplicationInsights",
       "Args": {
         "telemetryConverter": "Serilog.Sinks.ApplicationInsights.TelemetryConverters.TraceTelemetryConverter, Serilog.Sinks.ApplicationInsights"
       }
     }
   ]
 }
}

The connectionString argument is optional if the Application Insights connection string has either been placed in a APPLICATIONINSIGHTS_CONNECTION_STRING environment variable or application setting, when using an App Service.

Note that depending on the exact version numbers, you may need to add assembly redirection:

<dependentAssembly>
 <assemblyIdentity name="Microsoft.ApplicationInsights" publicKeyToken="31bf3856ad364e35" culture="neutral" />
 <bindingRedirect oldVersion="0.0.0.0-2.21.0.429" newVersion="2.21.0.429" />
</dependentAssembly>