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

Difference between revisions of "Logging"

(Excel add-in)
 
(11 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
From XLCubed v10.0.150 it has become possible to capture logs from XLCubed activity.
 
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 {{Code|appsettings.json}}.
+
== Configuration ==
* For the web this is deployed by default and will log to a file in the Logs sub-directory.
 
* For Excel this file should be created in the {{Code|%appsettings%\XLCubed Ltd\XLCubed Excel Edition}} folder (you can type this address into Explorer to go to the correct folder)
 
  
If you configure logs to be sent to the debug output you can capture them using [https://learn.microsoft.com/en-us/sysinternals/downloads/debugview DebugView] a free tool from Microsoft.
+
The log configuration can have different output targets which you can configure as shown below.  
  
You should use the version of the tool that matches the bit-ness of Excel and enable "Capture Win32" from the Capture menu.
+
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
  
 +
=== Excel add-in ===
 +
You can enable logging in the add-in options:
 +
{{Menu|Options|XLCubed Options|User Interaction tab|Enable Logging}}
  
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 then pick a folder and file name to log to. e.g. {{code|C:\temp\error.log}}
 +
 
 +
==== Manually enabling the Excel add-in log ====
 +
Create the {{Code|appsettings.json}} log configuration file in {{Code|%appdata%\XLCubed Ltd\XLCubed Excel Edition}} (you can type this address into File Explorer to go to the correct folder) then restart Excel.
 +
 
 +
=== Web ===
 +
By default, the {{Code|appsettings.json}} log configuration file is deployed in the {{Code|/XLCubedWeb}} installation directory, and will log to a file in the {{Code|Logs}} sub-directory.
  
 
== Sample configurations ==
 
== Sample configurations ==
  
This will log to the debug output, which you can capture using [https://learn.microsoft.com/en-us/sysinternals/downloads/debugview DebugView] a free tool from Microsoft.
+
=== File logging ===
 +
 
 +
This will log Verbose messages to a file.
 +
Note that backslashes in the file path must be doubled.
  
 
  {
 
  {
 
   "Serilog": {
 
   "Serilog": {
     "MinimumLevel": "Debug",
+
     "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 [https://learn.microsoft.com/en-us/sysinternals/downloads/debugview 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": [
 
     "WriteTo": [
 
       { "Name": "Debug" }
 
       { "Name": "Debug" }
Line 25: Line 64:
 
  }
 
  }
  
This will Verbose messages to the debug window and log Error to a file.
+
=== Microsoft Application Insights ===
Note that backslashes in the file path must be doubled.
+
 
 +
You can enable [https://learn.microsoft.com/en-us/azure/azure-monitor/app/app-insights-overview Microsoft Application Insights] by copying [https://www.nuget.org/packages/Serilog.Sinks.ApplicationInsights/ Serilog.Sinks.ApplicationInsights.dll] and [https://www.nuget.org/packages/Microsoft.ApplicationInsights/ Microsoft.ApplicationInsights.dll] into the installation folder (the {{Code|bin}} folder for a web installation) and setting your {{Code|appsettings.json}} to load them:
  
 
  {
 
  {
 
   "Serilog": {
 
   "Serilog": {
 +
    "Using": [
 +
      "Serilog.Sinks.ApplicationInsights"
 +
    ],
 
     "MinimumLevel": "Verbose",
 
     "MinimumLevel": "Verbose",
 
     "WriteTo": [
 
     "WriteTo": [
      { "Name": "Debug" } ,
 
 
       {
 
       {
         "Name": "File",
+
         "Name": "ApplicationInsights",
 
         "Args": {
 
         "Args": {
           "path": "C:\\Path\\To\\Logs\\error.log",
+
           "telemetryConverter": "Serilog.Sinks.ApplicationInsights.TelemetryConverters.TraceTelemetryConverter, Serilog.Sinks.ApplicationInsights"
          "rollingInterval": "Day",
 
          "retainedFileCountLimit": 10,
 
          "restrictedToMinimumLevel": "Error"
 
 
         }
 
         }
 
       }
 
       }
Line 45: Line 84:
 
   }
 
   }
 
  }
 
  }
 +
 +
The {{Code|connectionString}} argument is optional if the Application Insights connection string has either been placed in a {{Code|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>
 +
 +
[[Category:Logging]]

Latest revision as of 13:18, 31 October 2023

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

Configuration

The log configuration can have different output targets which you can configure as shown below.

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

Excel add-in

You can enable logging in the add-in options: Options > XLCubed Options > User Interaction tab > Enable Logging

You will have to restart Excel if you change the configuration.

You can then pick a folder and file name to log to. e.g. C:\temp\error.log

Manually enabling the Excel add-in log

Create the appsettings.json log configuration file in %appdata%\XLCubed Ltd\XLCubed Excel Edition (you can type this address into File Explorer to go to the correct folder) then restart Excel.

Web

By default, the appsettings.json log configuration file is deployed in the /XLCubedWeb installation directory, and will log to a file in the Logs sub-directory.

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>