Logging Agent - C Sharp
Write a log.
Logic Type | Available |
---|---|
Generic logic | ✅ |
Aggregator logic | ✅ |
Logs will be collected in the task's task result and look like this:
2023-12-31T12:59:59.000000000+00:00 Info plaintext some logging
2024-01-01T01:00:00.000000000+00:00 Error json {"error":true,"errorMessage":"some error","stack":"Error: some error...","taskId":"..."}
info
Logs output with Console.Write()
or Console.WriteLine()
will not show up in the execution result.
Import and Usage
The agent can be used without using additional namespaces:
public static class Logic
{
public static async Task Run(Context ctx)
{
await LoggingAgent.Info("some logging");
}
public static async Task HandleError(Context ctx, Exception error)
{
await LoggingAgent.Error("some error");
}
}
Class Reference
Type
- Public static class
LoggingAgent
Methods: Write a Log
- Error
- Warn
- Info
- Debug
- Trace
- Log
public async static Task Error(string message) {}
public async static Task Error(object message) {}
Parameter | Description |
---|---|
value | A string message or "JSON" object |
Write a log with Error
severity level.
public async static Task Warn(string message) {}
public async static Task Warn(object message) {}
Parameter | Description |
---|---|
value | A string message or "JSON" object |
Write a log with Warn
severity level.
public async static Task Info(string message) {}
public async static Task Info(object message) {}
Parameter | Description |
---|---|
value | A string message or "JSON" object |
Write a log with Info
severity level.
public async static Task Debug(string message) {}
public async static Task Debug(object message) {}
Parameter | Description |
---|---|
value | A string message or "JSON" object |
Write a log with Debug
severity level.
public async static Task Trace(string message) {}
public async static Task Trace(object message) {}
Parameter | Description |
---|---|
value | A string message or "JSON" object |
Write a log with Trace
severity level.
public async static Task Log(string level, string message) {}
Parameter | Description |
---|---|
level | Log severity level |
value | A string message or "JSON" object |
Write a log with custom severity level.
warning
Using objects of user-defined class will cause the fields not parsed properly.
Use Dictionary or JsonObject instead.
The methods represent different logging severity levels:
Log Type | Severity |
---|---|
Error | Highest |
Warn | |
Info | |
Debug | |
Trace | Lowest |