skip to Main Content

NLog: how to specify log folder at runtime – Asp.net

For an example, i have following code (ASP.NET core 6): Program.cs: //... var config = new NLog.Config.LoggingConfiguration(); var logfile = new NLog.Targets.FileTarget("logfile") { FileName = Path.Combine(AppFolderPath, "log", "${var:myLogName}", "log_${date:format=dd-MM-yyyy}.txt") }; config.AddRule(NLog.LogLevel.Trace, NLog.LogLevel.Fatal, logfile); LogManager.Configuration = config; //... Startup.cs: public void…

VIEW QUESTION

How to convert a date in the form of a string with this format (yyyy-MM-dd HH:mm:ss) to a DateTime object of this format (dd-MM-yyyy HH:mm:ss) – Asp.net

I'm currently using C# and I want to convert a string like "2022-01-15 18:40:30" to a DateTime object with this format "15-01-2022 18:40:30". Below is what I've tried. string stringDate = "2022-01-15 18:40:30"; string newStringDate = DateTime.ParseExact(date, "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture).ToString("dd-MM-yyyy…

VIEW QUESTION
Back To Top
Search