Log Class
Provides access to the global Carmenta Engine log.
NuGet/Assembly: Carmenta.Engine.5.16.2.nupkg (in the CECore assembly)
Syntax
public class Log : System.Object
Remarks
This class provides static methods, properties and events that can be used to configure the global Carmenta Engine log.
Carmenta Engine writes messages to the log to report various information. Each message is of a particular severity level and if that level matches or exceeds the current log level as specified by LogLevel it is forwarded to all log appenders that have been added to the Log. If EnableEvents is True it will also fire the MessageWritten event.
There are two log appenders available that an application can make use of.
DebuggerLogAppender writes log messages to an attached debugger. This appender should only be used during development and in debug builds.
RollingFileLogAppender writes log message to a rolling file log.
The Log class can be configured before Runtime.Initialize is called.
Example
// Configure the Log to log all warnings, or more severe, message to disk
public static void LogWarningsToFile(string fileName)
{
// Initialze the Carmenta Engine log with a rolling file
// log appender that uses the default file count of four
// and default file size of 10MB
RollingFileLogAppender appender = new RollingFileLogAppender(fileName);
// Add the appender to the log
Log.AddAppender(appender);
// Change the log level to Warning which means that all
// log messages of level Warning, Error and Fatal will be
// written to the rolling file
Log.LogLevel = LogLevel.Warning;
}
Inheritance Hierarchy
System.Object (not available in C#)
Log
Platforms
Windows, Linux, Android
Log Members
The Log type has the following members.
Properties
Name | Description |
---|---|
Determines whether the MessageWritten event is fired. | |
Specifies the minimum level of messages that will be sent to registered appenders and fire events. |
Methods
Name | Description |
---|---|
Adds a LogAppender to the list of registered appenders. | |
Removes all log appenders. | |
Removes the specified LogAppender from the list of registered appenders. |
Events
Name | Description |
---|---|
Occurs when events are enabled (see EnableEvents) and a log message that matches or exceeds the current log level is written to the log. |