Skip to end of metadata
Go to start of metadata

There are many information stored in the LogEntry such as message, category, severity, timestamp, priority, event ID and more. Printing out all of these information in the output window or any other repository might make the log entry illegible.

By default, Crosslight Logging Framework provides format string output for LogEntry for better readability. However, you can further customize the format of your log entry using ILogFormatter.

To learn more about the Crosslight logging concept in general, see Implementing Application Logging.

On this page:

Customizing Default Log Format

To customize the default log format, you can set the Formatter property with your format as follows.

Notice that each log entry value is represented with a specific token. The following is the associated token with information in log entry.

Log EntryToken
TimeStamp{timestamp}
Category{category}
Severity{severity}
Priority{priority}
EventId{eventid}
ActivityId{activity}
Extended Properties{dictionary({key} - {value})}
 {newline}
 {tab}

Creating Custom Log Formatter

Alternatively you can create a custom log formatter to format your log entry. For example, if you want to format your log entry with JSON format you can create a new JsonFormatter that inherits the LogFormatter class as follows.

You can now use the new log formatter as your LogWriter as follows.

Samples

To learn more about application logging in Crosslight and see how it works, please checkout the following samples: