Logging#
Info
Critical Manufacturing offers an Observability service that includes access to a comprehensive set of dashboards that includes logs, metrics and traces of all Critical Manufacturing Platform components.
For more information please contact your Account Manager or visit https://portal.criticalmanufacturing.com/Help/
This document describes how you can change some of the relevant configuration regarding logging and monitoring of the database and application layers. All Critical Manufacturing components make their logs available through STDOUT and also through OpenTelemetry, using Open Telemetry Specification 1.34.0.
Application Level Logging#
Most of our components use Log4Net (DotNet) or Winston (Node.js) as logging frameworks. Below you can find the instructions on how to configure them.
Host Logging#
The logging configuration is available as a ConfigMap called log4net that you can edit. By default the system only logs Warning or Error messages to the console. The log4net framework allows to manipulate configuration data relatively easy and you can change the default behavior by altering the ConfigMap.
Example configuration to start logging errors to a file:
<appender name="cmfErrorFileAppender" type="log4net.Appender.RollingFileAppender">
<file value="Host.log" />
<appendToFile value="true" />
<rollingStyle value="Size" />
<maxSizeRollBackups value="100" />
<maximumFileSize value="20MB" />
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
<layout type="log4net.Layout.PatternLayout">
<IgnoresException value="False" />
<conversionPattern value="[%date] [%thread] [%-5level]%newlineCategory: %property{Category}%newlineUserName: %property{User}%newlineTenantName: %property{TenantName}%newlineHostName: %property{HostName}%newlineUniversalMessage: %property{UniversalMessage}%newlineMessage: %message%newlineException: %exceptionInnerException: %property{InnerException}" />
</layout>
<filter type="log4net.Filter.LevelRangeFilter">
<levelMin value="ERROR" />
<levelMax value="FATAL" />
</filter>
</appender>
The above configuration generates a log file like:
[2018-02-27 22:41:56,981] [4] [ERROR]
Category: Cache
UserName: ######
TenantName: #######
HostName: #####
UniversalMessage: The data for the EntityType with Id=1712301249190000052 was not found in the system.
Message: The data for the EntityType with Id=1712301249190000052 was not found in the system.
Exception:
Message = The data for the EntityType with Id=1712301249190000052 was not found in the system.
StackTrace = at Cmf.Foundation.BusinessObjects.EntityType.DatabaseLoadAndValidation(CmfEntities model, Boolean IsOnlyGetInfo) in E:\Agents\A6\2\s\Biz\Core\BusinessObjectsBase\EntityType\EntityType.cs:line 4353
at Cmf.Foundation.BusinessObjects.EntityType.DatabaseLoadAndValidation(CmfEntities model) in E:\Agents\A6\2\s\Biz\Core\BusinessObjectsBase\EntityType\EntityType.cs:line 3645
at Cmf.Foundation.BusinessObjects.CacheManager.EntityTypeObjectCache.GetFromDatabase(EntityType entity) in E:\Agents\A6\2\s\Biz\Core\BusinessObjectsBase\CacheManager\EntityTypeObjectCache.cs:line 97
at Cmf.Foundation.BusinessObjects.CacheManager.EntityTypeObjectCache.Reload(EntityType entityType) in E:\Agents\A6\2\s\Biz\Core\BusinessObjectsBase\CacheManager\EntityTypeObjectCache.cs:line 179
at Cmf.Foundation.BusinessObjects.CacheManager.EntityTypeObjectCache.ReloadLoad(Int64 id) in E:\Agents\A6\2\s\Biz\Core\BusinessObjectsBase\CacheManager\EntityTypeObjectCache.cs:line 223
at Cmf.Foundation.BusinessObjects.CacheManager.EntityTypeObjectCache.Remove(Int64 entityId) in E:\Agents\A6\2\s\Biz\Core\BusinessObjectsBase\CacheManager\EntityTypeObjectCache.cs:line 323
at Cmf.Foundation.Common.CmfCacheManager`2.RemoveFromCache(Int64 id) in C:\Product\CoreBiz\Biz\Core\Common\Cache\CmfCacheManager.cs:line 392
at Cmf.Foundation.Services.Host.Handlers.MulticastHandler.ProcessEntityTypeCache(List`1 cacheEntryNames, List`1 cacheEntryIds) in E:\Agents\A6\2\s\Biz\Services\Hosting\ServiceHost\Handlers\MulticastHandler.cs:line 312
at Cmf.Foundation.Services.Host.Handlers.MulticastHandler.InvalidateCache(String msg) in E:\Agents\A6\2\s\Biz\Services\Hosting\ServiceHost\Handlers\MulticastHandler.cs:line 1065
Source = Cmf.Foundation.BusinessObjects
Don't forget to add the new appender to the root node.
<!--Appenders-->
<!--Root Configuration. Add extra Appenders or set the logging level (ALL, DEBUG, INFO, WARN, ERROR, FATAL, OFF)-->
<root>
<level value="ALL" />
<!-- Keep existing appender(s) -->
<appender-ref ref="cmfErrorFileAppender" />
</root>
For more advanced settings please refer to log4net official documentation ⧉.
Integrating with other APM Solutions#
You can integrate our supported observable components in your existing Application Performance Monitoring (APM) if your APM is compliant with OpenTelemetry 1.34.0 or above. Please review the environment variables documentation, with relevance to the ones prefixed with OBSERVABILITY_.
Warning
This configuration cannot be done through DevOps Center. In order to do so, you need to apply a cluster policy that alters the values of OBSERVABILITY_ environment variables according to your APM's requirements.