Logging in Sitecore Managed Cloud containers

Abstract

Overview of logging for Sitecore Managed Cloud containers.

Sitecore Managed Cloud containers use an ELK stack to collect and aggregate the log files that are output by the various containers in a Kubernetes cluster. The following diagram illustrates the data flow for a Windows based, Sitecore role container:

ELK_stack_data_flow.png

Customize the logging of Sitecore roles

You can customize the logging for a Sitecore role in a Managed Cloud container. To customize the logging for a Sitecore role, you modify the Stdout of the container by editing the configuration file of the Log Monitor. The configuration file for the Log Monitor is stored in C:\LogMonitor\logmonitorconfig.json in each container image.

Note

Increasing the number of log files generated by your AKS cluster can cause storage issues in the Elasticsearch database. This can lead to the loss of some logged data. The retention period for Elasticsearch data is set to 30 days by default.

The base configuration that collects both Sitecore logs, and IIS logs is:

{
    "LogConfig": {
        "sources": [
            {
                "type": "File",
                "directory": "c:\\inetpub\\logs",
                "filter": "*.log",
                "includeSubdirectories": true
            },
            {
                "type": "File",
                "directory": "c:\\inetpub\\wwwroot\\App_data\\logs",
                "filter": "log.*.txt",
                "includeSubdirectories": false
            }
        ]
    }
}

To update the logmonitorconfig.json file, create a new config file and build it into a custom image.

Common LogMonitor custom configurations

Output all Sitecore logs:

{
    "LogConfig": {
        "sources": [
            {
                "type": "File",
                "directory": "c:\\inetpub\\logs",
                "filter": "*.log",
                "includeSubdirectories": true
            },
            {
                "type": "File",
                "directory": "c:\\inetpub\\wwwroot\\App_data\\logs",
                "filter": "*.txt",
                "includeSubdirectories": false
            }
        ]
    }
}

Output Windows events and system logs:

{
    "LogConfig": {
        "sources": [
            {
                "type": "EventLog",
                "startAtOldestRecord": true,
                "eventFormatMultiLine": false,
                "channels": [
                    {
                         "name": "system",
                         "level": "Information"
                    },
                    {
                         "name": "application",
                         "level": "Error"
                    }
                ]
            },
            {
                "type": "File",
                "directory": "c:\\inetpub\\logs",
                "filter": "*.log",
                "includeSubdirectories": true
            },
            {
                "type": "File",
                "directory": "c:\\inetpub\\wwwroot\\App_data\\logs",
                "filter": "log.*.txt",
                "includeSubdirectories": false
            }
        ]
    }
}