-
Notifications
You must be signed in to change notification settings - Fork 0
.NET Core Console Application
Chad Ramos edited this page Mar 24, 2019
·
12 revisions
Add a appsettings.json
file to your project and ensure it is set its "Copy to Output Directory" property to "Copy if newer".
{
"PioneerLogsConfiguration": {
"ApplicationName": "Pioneer Logs",
"ApplicationLayer": "Samples.AspNetCore",
"Errors": {
"WriteToFile": false,
"WriteToConsole": true
},
"Usage": {
"WriteToFile": false,
"WriteToConsole": true
},
"Performance": {
"WriteToFile": false,
"WriteToConsole": true
},
"Diagnostics": {
"WriteToFile": true,
"WriteToConsole": true
}
}
}
Default write
targets are demonstrated above. You can override both console
and file globally, per log category. If you need to overwrite on a log to log context, you can provide the forceWriteToFile
flag to any category.
PioneerLogsTub.LogError("Oh NO!!!", forceWriteToFile: true);
Register the Tub to setup up global exception handling.
private static void Main(string[] args)
{
_config = PioneerLogsTub.RegisterLogger();
....
}
private static void PerformanceTest()
{
PioneerLogsTub.StartPerformanceTracker();
System.Threading.Thread.Sleep(1000);
PioneerLogsTub.StopPerformanceTracker();
}
public static void LogUsage(string message, Dictionary<string, object> additionalInfo = null, bool forceWriteToFile = false);
public static void LogDiagnostic(string message, Dictionary<string, object> additionalInfo = null, bool forceWriteToFile = false);
public static void LogError(Exception ex, bool forceWriteToFile = false);
public static void LogError(string message, bool forceWriteToFile = false);
public static void LogError(Exception ex, string message, bool forceWriteToFile = false);