Logging Targets
This page contains information that is specific to the available log targets, but does not cover the logging framework in general. Ensure that you read the logging page and others in the section thoroughly.
The logging framework supports a number of targets initially, with the potential for more to be supported in the future. The supported targets are currently:
- The default log target,
- File targets,
- Event log targets,
- Database targets,
- Mail targets
- Visual Studio Output Window
The targets are configured within M-Files Admin. Each target typically supports the following common properties:
Enabled
- enables logging to this targetMinimum Log Level
- the minimum log level (inclusive) that is logged to this targetMaximum Log Level
- the maximum log level (inclusive) that is logged to this targetAdvanced
Layout
- an instruction on how the log message (and other environmental information) should be formatted in the target. In the current implementation these use the NLog implementation, with some additional custom layout renderersLog Sensitivity
- details on the sensitivity level that should be applied to this target
Some targets can only be configured by system administrators. Often these targets are incompatible with cloud infrastructures. More details are available in each target’s dedicated documentation below.
Default log target
The default log target is supported within the M-Files Cloud infrastructure.
The default log target logs to a standardized location on disk. The default log target supports the following properties:
Enabled
- changeable by vault administrators and system administratorsMinimum Log Level
- changeable by vault administrators and system administratorsMaximum Log Level
- changeable by vault administrators and system administratorsLog File Rotation
- how to rotate and archive files created by this target, changeable by system administratorsAdvanced
Layout
- changeable by vault administrators and system administratorsKeep File Open
- changeable by system administratorsAllow Concurrent Writes
- changeable by system administratorsLog Sensitivity
- changeable by vault administrators and system administrators
In on-premises implementations, the default log target will log to an area within the secondary vault location. The exact folder location will depend on your M-Files configuration, but is typically of the format C:\Program Files\M-Files\Server Vaults\{VaultName}\AppLogs\
. Inside this folder it will create a folder with the GUID of the application, within that a folder with the GUID of the server ID, within that a folder with a numeric name, and within that it will create text files according to the configured log rotation/archival settings (e.g. C:\Program Files\M-Files\Server Vaults\Sample Vault\AppLogs\6502bb5f-a696-4faa-848a-3f7d5847e00b\f8063303-4501-44b1-8f92-8441959263b3\0\current.log
.)
In on-premises implementations before M-Files 22.4, the default log target will log to a Logs
directory inside the system temporary folder, e.g. C:\Windows\Logs\
. Inside this folder it will create a folder with the GUID of the vault, within that a folder with the GUID of the application, within that a folder with the GUID of the server ID, and within that it will create text files according to the configured log rotation/archival settings (e.g. C:\Windows\Temp\logs\2722f9ab-b96b-4db5-b1a1-8e0618d289b7\6502bb5f-a696-4faa-848a-3f7d5847e00b\f8063303-4501-44b1-8f92-8441959263b3\current.log
).
In M-Files Cloud implementations this is to a persistent storage location. Note that files in this storage location may be removed by operational processes such as service breaks, or archived due to size or age. For this reason logs should be considered as temporary and transient, not for long-term use.
The default log target additionally copies the appdef.xml
file from the vault application into the log location. This can be used to more easily identify the application that the logs are for.
File targets
Custom file target locations are not supported within the M-Files Cloud infrastructure.
File targets log to custom locations on disk. The file log target supports the following properties:
Name
- changeable by vault administrators and system administratorsEnabled
- changeable by vault administrators and system administratorsMinimum Log Level
- changeable by vault administrators and system administratorsMaximum Log Level
- changeable by vault administrators and system administratorsFolder Name
- changeable by vault administrators and system administratorsFile Name
- changeable by vault administrators and system administratorsLog File Rotation
- how to rotate and archive files created by this target, changeable by vault administrators and system administratorsAdvanced
Layout
- changeable by vault administrators and system administratorsKeep File Open
- changeable by system administratorsAllow Concurrent Writes
- changeable by system administratorsLog Sensitivity
- changeable by vault administrators and system administrators
Event log targets
Event log targets are not supported within the M-Files Cloud infrastructure.
Event log targets write to the Windows Event Log. The Event Log target supports the following properties:
Name
- changeable by vault administrators and system administratorsEnabled
- changeable by vault administrators and system administratorsMinimum Log Level
- changeable by vault administrators and system administratorsMaximum Log Level
- changeable by vault administrators and system administratorsMachine Name
- changeable by vault administrators and system administratorsSource
- changeable by vault administrators and system administratorsLog
- changeable by vault administrators and system administratorsEvent ID
- changeable by vault administrators and system administratorsAdvanced
Layout
- changeable by vault administrators and system administratorsMaximum Message Size
- changeable by system administratorsOverflow Action
- changeable by system administratorsLog Sensitivity
- changeable by vault administrators and system administrators
Database targets
Database targets are supported within the M-Files Cloud infrastructure.
Database targets write log data into a target OLEDB database. The database target supports the following properties:
Name
- changeable by vault administrators and system administratorsEnabled
- changeable by vault administrators and system administratorsMinimum Log Level
- changeable by vault administrators and system administratorsMaximum Log Level
- changeable by vault administrators and system administratorsHost Name
- changeable by vault administrators and system administratorsDatabase Name
- changeable by vault administrators and system administratorsAuthentication Type
- changeable by vault administrators and system administratorsCommand Text
- changeable by vault administrators and system administratorsParameters
- changeable by vault administrators and system administratorsAdvanced
Layout
- changeable by vault administrators and system administratorsLog Sensitivity
- changeable by vault administrators and system administrators
When using a database target, the Command Text
property sets the SQL statement to use (e.g. insert into dbo.Log (MachineName, Logged, Level, Message, Logger, Callsite, Exception) values ( @MachineName, @Logged, @Level, @Message, @Logger, @Callsite, @Exception )
). Each parameter in the command text (e.g. @MachineName
) is then created in the Parameters
collection, and assigned data from the event itself.
Mail targets
Mail targets are supported within the M-Files Cloud infrastructure.
Mail targets send log data to a mail server. The mail target supports the following properties:
Name
- changeable by vault administrators and system administratorsEnabled
- changeable by vault administrators and system administratorsMinimum Log Level
- changeable by vault administrators and system administratorsMaximum Log Level
- changeable by vault administrators and system administratorsSubject
- changeable by vault administrators and system administratorsFrom
/To
/CC
/BCC
- changeable by vault administrators and system administratorsSMTP Configuration
Server Address
- changeable by vault administrators and system administratorsUse Encrypted Connection
- changeable by vault administrators and system administratorsPort
- changeable by vault administrators and system administratorsAuthentication Mode
- changeable by vault administrators and system administratorsUse Local Pickup Folder
- changeable by system administrators
Advanced
Layout
- changeable by vault administrators and system administratorsEncoding
- changeable by vault administrators and system administratorsHeader
- changeable by vault administrators and system administratorsFooter
- changeable by vault administrators and system administratorsAdd Newlines Between Messages
- changeable by vault administrators and system administratorsReplace Newlines with HTML Breaks
- changeable by vault administrators and system administratorsLog Sensitivity
- changeable by vault administrators and system administrators
Visual Studio Output Window
The framework supports the easy logging of information to the Visual Studio Debug window via the LogManager.EnableLoggingToAttachedDebugger
and LogManager.DisableLoggingToAttachedDebugger
methods. This can be very useful when initially developing an application.
To start logging to this target, call the appropriate method during your application initialization, e.g.:
public VaultApplication()
{
#if DEBUG
// Enable logging to any attached debugger, but do not launch the debugger.
LogManager.EnableLoggingToAttachedDebugger
(
new AttachedDebuggerLoggingSettings()
{
LaunchDebugger = false, // If true, will pop up the "Attach a debugger" dialog at this point.
MinimumLogLevel = LogLevel.Debug,
MaximumLogLevel = LogLevel.Fatal
}
);
#endif
}
Once attached, log messages can be found in the Debug window in Visual Studio:
Future targets
M-Files are currently considering adding support for additional targets, including:
Application Insights
Application Insights is a feature of Azure Monitor that provides extensible application performance management (APM) and monitoring for applications. Future extensions of the logging library may allow customers to log to their own Application Insights instance.