NLog
We recommend enabling logging to verify that the new functionality operates as expected. For optimal performance, enable logging only while testing and debugging Creatio. Creatio can log all primary operations. This is achieved using the NLog library, a free .NET logging library that supports routing features and log management. NLog is suitable for any Creatio instance regardless of size or complexity.
The library lets you perform the following actions:
- handle diagnostic messages sent in any .NET language
- enrich logs with contextual data
- format logs based on user preferences
- send logs to one or more message receivers, such as a file or database
Learn more about the NLog: official vendor website (GitHub).
Set up logging for Creatio on-site
Creatio logs events for the loader and Default
configuration separately.
You can set up logging for Creatio on-site in the following ways:
- via the configuration file
- via the
LoggingConfiguration
configuration object
Set up logging for Creatio on-site via the configuration file
1. Set the path to the log configuration file
You can set up logging in the following configuration files of the ..\Terrasoft.WebApp
directory:
nlog.config
nlog.targets.config
Set the path to the nlog.config
file in the ..\Terrasoft.WebApp\Web.config
configuration file.
<common>
<logging>
<factoryAdapter type="Common.Logging.NLog.NLogLoggerFactoryAdapter, Common.Logging.NLog45">
<arg key="configType" value="FILE" />
<arg key="configFile" value="~/nlog.config" />
</factoryAdapter>
</logging>
</common>
2. Specify the log receivers
Log receivers display, store and transfer the log messages to other receivers.
Log receivers have the following types:
- receivers that receive and handle messages
- receivers that buffer or forward messages to another receiver
Specify the log receivers in the <target>
XML element of the ...\Terrasoft.WebApp\nlog.targets.config
file.
The configuration attributes of log receivers are as follows:
-
name
. Receiver name. -
xsi:type
. Receiver type. Available values: "File," "Database," "Mail." -
fileName
. Log file and path to the log file. The log file location depends on the values of Windows system variables.- Default path to the application loader log files
- Path example
[TEMP]\Creatio\Site_[SiteId][ApplicationName]\Log[DateTime.Today]
C:\Windows\Temp\Creatio\Site_1\creatio806\Log\2022_05_22
- Path to the Default configuration log files
- Path example
[TEMP]\Creatio\Site_[SiteId][ApplicationName][ConfigurationNumber]\Log[DateTime.Today]
C:\Windows\Temp\Creatio\Site_1\creatio806\0\Log\2022_05_22
-
[TEMP]
. Base directory. By default, IIS uses theC:\Windows\Temp
directory. Visual Studio (IIS Express) uses theC:\Users[User name]\AppData\Local\Temp
directory. -
[SiteId]
. Website number. For IIS, find the website number in the advanced website settings. For Visual Studio, the number is 2. -
[ApplicationName]
. Creatio name. -
[ConfigurationNumber]
. Configuration number. The number for theDefault
configuration is usually 0. -
[DateTime.Today]
. Log date. -
layout
. Template for populating the log file.Example of the nlog.targets.config file<target name="universalAppender" xsi:type="File"
layout="${DefaultLayout}"
fileName="${LogDir}${LogDay}${logger:shortName=True}.log" />
Learn more about log receivers: official vendor documentation (NLog).
3. Define the log rules
You can define the log rules in the nlog.config
file.
The configuration attributes of log rules are as follows:
-
name
. Log name. -
minlevel
. Minimum logging level. The default logging level for Creatio components is set to ensure the highest performance.Available logging levels in ascending priority:
Trace
. Log all events during setup. Set the initial and final methods.Debug
. Log all events during debugging.Info
. Log regular Creatio activity.Warn
. Log warnings. Creatio continues to operate after logging.Error
. Log errors that might crash Creatio.Fatal
. Log errors that inevitably crash Creatio.Off
. Disable logging.
-
maxlevel
. Maximum logging level. -
level
. Log events of a specific logging level. -
levels
. Log events of multiple logging levels, separated by commas. -
writeTo
. The name of the log receiver. -
final
. Whether to handle subsequent rules. -
enabled
. Disable the log rule (set tofalse
) without deleting it. -
ruleName
. The log rule ID.
NLog handles logging rule attributes in the following order:
level
levels
minlevel
andmaxlevel
If minLevel = "Warn" level = "Info"
, only the Info
logging level is used, because the handling priority of the level
attribute is higher than minLevel
.
<logger name="IncidentRegistration" writeTo="AdoNetBufferedAppender" minlevel="Trace" final="true" />
Set up logging for Creatio on-site via the LoggingConfiguration configuration object
- Create a
LoggingConfiguration
object that describes the configuration. - Create the log receivers.
- Set up the properties of the log receivers.
- Define the logging rules using
LoggingRule
objects. - Add the logging rules to the
LoggingRules
configuration objects. - Activate the configuration. To do this, specify the created configuration object in
LogManager.Configuration
.
Set up logging for Creatio in the cloud
To set up logging for Creatio in the cloud, contact Creatio support.
It is impossible to add an additional log receiver when setting up logging for Creatio in the cloud.