EOS FunctionAPI leverages the .NET core logging architecture for logging messages and diagnostics. This allows EOS FunctionAPI to log to different log storages including files, event log or Application Insights.
Logging is configured by modifying the appsettings.json
file of your service instance. This file is found in the folder of EOS FunctionAPI and can be modified with your text editor of choice.
As of today, EOS FunctionAPI supports logging to the following storages:
Thos logging infrastructure allows you to select which messages are logged and which are not. You can filter them by log source, or severity, or even configure the severity to be logged based on the log source. You can find more information on the documentation of Logging in .NET Core and ASP.NET Core
You can configure EOS FunctionAPI to emit logs to an Application Insights account. You must first create an Application Insights account on Azure and get the Instrumentation Key or Connection String. One of them is required to set up logging to Application Insights.
After you have configured the use of Application Insights, you must restart your service instance. Please note that it can take up to 5min until the log messages appear on your Application Insights storage.
Using Connection String
After you have obtained the connection string for your Application Insights account, you can connect your EOS FunctionAPI to it. Open the appsettings.json
file of your service instance and create the following section anywhere inside the main JSON object:
{
...
"ApplicationInsights": {
"ConnectionString": "<your-connection-string-goes-here>"
}
...
}
Using Instrumentation Key
After you have obtained the instrumentation key for your Application Insights account, you can connect your EOS FunctionAPI to it. Open the appsettings.json
file of your service instance. Then create or locate the general configuration setting for EOS FunctionAPI called EosFunctionApi and create a property called ApplicationInsightsInstrumentationKey like so:
{
...
"EosFunctionApi": {
...
"ApplicationInsightsInstrumentationKey": "<your-instrumentation-key-goes-here>"
...
}
...
}
EOS FunctionAPI supports logging to a local file system. While this is very convenient for debugging issues or diagnostics sessions, we discourage it’s use in production environments. Using local file logging may in some cases slow down the response times of EOS FunctionAPI or even not write correctly to the file when the FunctionAPI is under high concurrent use or heavy load.
EOS FunctionAPI uses Nreco.Logging for logging to the file system. You can find more information about this component, how to configure it and what features it supports here: https://github.com/nreco/logging
To enable file logging, you must open the appsettings.json
of your EOS FunctionAPI instance. In this file, under the section Logging you must add the following JSON object:
{
"Logging": {
...
...
"File": {
"Path": "path/to/your/log.txt"
"Append": true
}
}
}
This is the basic configuration you need to enable for file logging to work. For mor information about each setting and what else you can configure, please check the documentation of Nreco.Logging.
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.