MBTiler API Appsettings
Below is the documentation for the appsettings.json configuration file in MBTiler.API. This documentation explains each section of the file, guiding you to understand and manage the application settings effectively.
Overview
The appsettings.json file specifies configuration settings for an ASP.NET Core application. It includes application-specific settings, such as connection strings, scheduler jobs, Azure configurations, and other application settings.
1. ConnectionStrings
{
"ConnectionStrings": {
"DefaultConnection": "{Your connection string comes here}"
}
}
Docker-compose form of environment variables.
environment:
ConnectionStrings__DefaultConnection:"{Your connection string comes here}"
- DefaultConnection: This signifies the database connection string, which is used to connect to your database.
2. MapConvertOptions
{
"MapConvertOptions": {
"MapsFolderName": "tiles",
"ContentFilesFolderName": "Content",
"ConvertedFilesFolderName": "ConvertedMbTiles",
"TempFilesFolderName": "/tmp/MbtilesTemp",
"TileFolderName": "TileFiles",
"ApprovedContentFolderName": "ApprovedContent",
"MetaDataFileName": "metadata.json",
"TippeCanoeCommand": "{0} && tippecanoe -Z5 -z16 -d16 -D12 -b32 -ac -ar -ao -r1 -pk -pf -pS --coalesce-densest-as-needed --drop-densest-as-needed -e {1} -f {2}*",
"TippeCanoeCommandFileType": ".geojson",
"ContentFilesType": ".zip"
}
}
Docker-compose form of environment variables.
environment:
MapConvertOptions__MapsFolderName: "tiles"
MapConvertOptions__ContentFilesFolderName: "Content"
MapConvertOptions__ConvertedFilesFolderName: "ConvertedMbTiles"
MapConvertOptions__TempFilesFolderName: "/tmp/MbtilesTemp"
MapConvertOptions__TileFolderName: "TileFiles"
MapConvertOptions__ApprovedContentFolderName: "ApprovedContent"
MapConvertOptions__MetaDataFileName: "metadata.json"
MapConvertOptions__TippeCanoeCommand: "{0} && tippecanoe -Z5 -z16 -d16 -D12 -b32 -ac -ar -ao -r1 -pk -pf -pS --coalesce-densest-as-needed --drop-densest-as-needed -e {1} -f {2}*"
MapConvertOptions__TippeCanoeCommandFileType: ".geojson"
MapConvertOptions__ContentFilesType: ".zip"
- MapsFolderName: The folder name where the map tiles are stored.
- ContentFilesFolderName: The folder name where content files are stored.
- ConvertedFilesFolderName: The folder name where converted map files are stored.
- TempFilesFolderName: The folder name where temporary files are stored.
- TileFolderName: The folder name where tile files are stored.
- ApprovedContentFolderName: The folder name where approved content is stored.
- MetaDataFileName: The name of the metadata file.
- TippeCanoeCommand: The command template for generating map tiles using Tip pecanoe.
- TippeCanoeCommandFileType: The file type used in the Tippecanoe command.
- ContentFilesType: The file type for content files.
3. AzureBlobSettings
{
"AzureBlobSettings": {
"ContentType": "application/x-protobuf",
"ContentEncoding": "gzip"
}
}
Docker-compose form of environment variables.
environment:
AzureBlobSettings__ContentType: "application/x-protobuf"
AzureBlobSettings__ContentEncoding: "gzip"
- ContentType: The content type for the Azure Blob Storage blobs, such as
application/x-protobuf. - ContentEncoding: This specifies the encoding type for the content, such as
gzip.
4. Serilog
{
"Serilog": {
"Using": [ "Serilog.Sinks.Console" ],
"MinimumLevel": {
"Default": "Information",
"Override": {
"Microsoft": "Information",
"System": "Information",
"Microsoft.EntityFrameworkCore.Database.Command": "Warning",
"Microsoft.AspNetCore.Mvc.Infrastructure.ObjectResultExecutor": "Warning"
}
},
"WriteTo": [
{
"Name": "Elasticsearch",
"Args": {
"nodeUris": "",
"basicAuthUsername": "",
"basicAuthPassword": "",
"apiKey": "",
"indexFormat": "apilogs-{logType}",
"autoRegisterTemplate": true,
"autoRegisterTemplateVersion": "ESv8",
"emitEventFailure": "WriteToSelfLog"
}
},
{
"Name": "Console",
"Args": {
"theme": "Serilog.Sinks.SystemConsole.Themes.SystemConsoleTheme::Literate, Serilog.Sinks.Console",
"outputTemplate": "[{Level} {@Timestamp:yyyy-MM-dd HH:mm:ss}] [Message: {Message} {Exception}]{NewLine}"
}
},
{
"Name": "CustomFile",
"Args": {
"path": "logs/log-.txt"
}
}
],
"Enrich": ["FromLogContext", "WithMachineName", "WithProcessId", "WithThreadId"],
"Destructure": [
{
"Name": "ToMaximumDepth",
"Args": { "maximumDestructuringDepth": 20 }
},
{
"Name": "ToMaximumStringLength",
"Args": { "maximumStringLength": 5000 }
},
{
"Name": "ToMaximumCollectionCount",
"Args": { "maximumCollectionCount": 20 }
}
],
"Properties": {
"Application": "Pointr.Microservice.MBTiler.API",
"AllowedMethods": ""
}
}
}
Docker-compose form of environment variables.
environment:
Serilog__Using__0: "Serilog.Sinks.Console"
Serilog__MinimumLevel__Default: "Information"
Serilog__MinimumLevel__Override__Microsoft: "Information"
Serilog__MinimumLevel__Override__System: "Information"
Serilog__MinimumLevel__Override__Microsoft.EntityFrameworkCore.Database.Command: "Warning"
Serilog__MinimumLevel__Override__Microsoft.AspNetCore.Mvc.Infrastructure.ObjectResultExecutor: "Warning"
Serilog__WriteTo__0__Name: "Elasticsearch"
Serilog__WriteTo__0__Args__nodeUris: "{Your Elasticsearch URL comes here}"
Serilog__WriteTo__0__Args__basicAuthUsername: "{Your Elasticsearch username comes here}"
Serilog__WriteTo__0__Args__basicAuthPassword: "{Your Elasticsearch password comes here}"
Serilog__WriteTo__0__Args__apiKey: "{Your Elasticsearch API key comes here (optional)}"
Serilog__WriteTo__0__Args__indexFormat: "apilogs-{logType}"
Serilog__WriteTo__0__Args__autoRegisterTemplate: "true"
Serilog__WriteTo__0__Args__autoRegisterTemplateVersion: "ESv8"
Serilog__WriteTo__0__Args__emitEventFailure: "WriteToSelfLog"
Serilog__WriteTo__1__Name: "Console"
Serilog__WriteTo__1__Args__theme: "Serilog.Sinks.SystemConsole.Themes.SystemConsoleTheme::Literate, Serilog.Sinks.Console"
Serilog__WriteTo__1__Args__outputTemplate: "[{Level} {@Timestamp:yyyy-MM-dd HH:mm:ss}] [Message: {Message} {Exception}]{NewLine}"
Serilog__WriteTo__2__Name: "CustomFile"
Serilog__WriteTo__2__Args__path: "logs/log-.txt"
Serilog__Enrich__0: "FromLogContext"
Serilog__Enrich__1: "WithMachineName"
Serilog__Enrich__2: "WithProcessId"
Serilog__Enrich__3: "WithThreadId"
Serilog__Destructure__0__Name: "ToMaximumDepth"
Serilog__Destructure__0__Args__maximumDestructuringDepth: "20"
Serilog__Destructure__1__Name: "ToMaximumStringLength"
Serilog__Destructure__1__Args__maximumStringLength: "5000"
Serilog__Destructure__2__Name: "ToMaximumCollectionCount"
Serilog__Destructure__2__Args__maximumCollectionCount: "20"
Serilog__Properties__Application: "Pointr.Microservice.MBTiler.API"
Serilog__Properties__AllowedMethods: ""
- Using: Specifies the Serilog sinks in use, such as
"Serilog.Sinks.Console"for console logging. - MinimumLevel: Sets the minimum logging level to
Information, with specific overrides available for Microsoft and System namespaces. - WriteTo: Defines where log output is sent. This configuration includes:
- Elasticsearch: Sends logs to Elasticsearch with configurable authentication and indexing options.
- Console: Outputs logs to the console with a custom theme and template.
- CustomFile: Writes logs to a file at
logs/log-.txt. - Enrich: Adds contextual data to logs, such as machine name, process ID, and thread ID.
- Destructure: Configures destructuring with limits on depth (20), string length (5000), and collection count (20) to manage log size and detail.
- Properties: Additional properties to include in every log, like specifying the application name and allowed methods.
Important Notes:
-
Elasticsearch authentication: API Key is preferred if available, otherwise Basic Auth (username/password) is used for connection.
-
The
WriteToarray allows multiple sinks to be configured simultaneously, enabling logs to be sent to console, file, and Elasticsearch at the same time. -
If the required configuration parameters for a sink are not provided, that sink will be silently skipped and no logs will be sent to it.
Notes:
This documentation is designed to make the configuration more comprehensible and guide you in making necessary adjustments where needed. It includes explanations of what each setting is for and important considerations when making changes.
5. Logging Details
Logged Activities
- Job Execution: This service primarily logs the details of MBTiles generation jobs directly to the database rather than middleware-based activity logging.
Logged Data Fields
- Job Context: ClientIdentifier, SiteIdentifier, Version.
- Status info: Status (e.g., Error, Done), StatusMessage (Error details).
- Storage Config: CloudStorageBaseURL, CloudStorageAccessToken, BucketName, Region, Provider.
- Artifacts: ContentURL (Source), ResultBlobUrl (Output).