using NLog; ILogger logger = LogManager.CreateLogger("MyLogger"); logger.Info("Hello, world!");
using NLog; using NLog.Targets; FileTarget target = new FileTarget("logfile") { FileName = "${basedir}/logs/${shortdate}.log", Layout = "${longdate} ${level} ${message} ${exception}" }; LoggingConfiguration config = new LoggingConfiguration(); config.AddTarget(target); config.LoggingRules.Add(new LoggingRule("*", LogLevel.Debug, target)); LogManager.Configuration = config; ILogger logger = LogManager.CreateLogger("MyLogger"); logger.Debug("Debugging message");This example creates a file target that writes log messages to a log file with a name based on the current date. The file target is added to the logging configuration and a new logger is created that writes a debugging message to the file. Overall, ILogManager and CreateLogger are part of the NLog library, which is a powerful logging framework for .NET applications. They provide a flexible way to create and manage named loggers that can be used to write log messages to various destinations.