Hi, try following Logger. Unfortunately, it is impossible for me to insert code into this buggy forum UI.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hello,
I need a tool that creates log files for me without blocking the application should be done in parallel.
Furthermore I need to be able to store the log file in this format. <NameOfApplication><YYYY-MM-dd>.log
If the size exceeds 50MByte a new file should be written. After 15 days, they should be deleted automatically.
Are there FreeTools for these requirements? Does anyone have a good sample code for C#, WPF, VS2017? Thanks in advance.
Regards Markus
Hi, try following Logger. Unfortunately, it is impossible for me to insert code into this buggy forum UI.
public class MainProgram
{
public static void Main(string[] args)
{
BasicLogger.Run();
.....
public class BasicLogger
{
public static void Run()
{
var logger = new LoggerConfiguration()
.WriteTo.ColoredConsole()
.WriteTo.RollingFile(@"c:\temp\Log-{Date}.txt")
.CreateLogger();
var appointment =
new { Id = 1, Subject = "Meeting of database migration", Timestamp = new DateTime(2020, 7, 11) };
logger.Information($"An appointment is booked successfully: {appointment.Id}");
logger.Error($"Failed #TEST# to book an appointment: {appointment.Timestamp}");
}
I've looked at it, it doesn't look bad.
how can i define the logger as global, that I can write from main
Do you have an example?
Unfortunately, it is impossible for me to insert code into this buggy forum UI.
Yes the old one was better.
Can you upload it please?