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 targets are configured within M-Files Admin. Each target typically supports the following common properties:

An example of configuring the log targets

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:

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.

Configuring the default target

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:

Configuring a file target

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:

Configuring an event log target

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:

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.

Configuring a database target

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:

Configuring a mail target

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:

Viewing log messages 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.