Skip to main content

UsingLogLayoutFormat Method

Configures the testbed to use a custom log layout format.

Definition​

Namespace: GHost.GSharp.Developer.Builder
Type: AssemblyBuilder
Assembly: GHost.GSharp.Developer.dll

public AssemblyBuilder UsingLogLayoutFormat(string logLayoutFormat)

Parameters​

logLayoutFormat string
The custom log layout format to use.

Return Value​

AssemblyBuilder
The same builder instance, to allow fluent configuration.

Example​

private void ConfigureAssembly(AssemblyBuilder builder)
{
builder
.UsingLogLayoutFormat("custom format")
.AddModule<TankVolume>(moduleBuilder => moduleBuilder
// ... configure points and contexts here
);
}

Remarks​

For the purposes of debugging and testing your calculation logic it is often helpful to only see a limited number of items in a log entry. The testbed provides, by default, the following information:

  • Abbreviated timestamp – The time when the log entry was generated, in HH:mm:ss format.
  • Log level – TRACE, DEBUG, INFO, WARN, ERROR or FATAL.
  • Message – The log message.
  • Exception – The exception, if applicable, including the stack trace.

These are usually sufficient for most scenarios. However, in some cases you may want to see more information for each log entry. This method produces more than just the standard log information. It includes the following extra detail:

  • Full timestamp – The time when the log entry was generated, in yyyy-MM-dd HH:mm:ss format.
  • Logger name – The area from which the log entry was generated.
  • Log code – Although not enforced in your module, each log entry generated by gSharp and the testbed contains a unique mnemonic log code.
  • Log context – In certain circumstances the same log can be generated from different contexts, so this can be helpful to differentiate them.

Strictly speaking, this method does not actually produce every piece of information that a log entry contains. However, the items that are ommited do not provide any information that you do not already have (such as the name of the application that generated the log, which will always be the testbed console app).

If you wish to customize the log layout format beyond what this method provides, you can use the UsingLogLayoutFormat method to specify exactly which information you want to see and how it is formatted.