Add project files.
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using NLog;
|
||||
using NLog.Targets;
|
||||
|
||||
namespace TURN.Libraries.Core
|
||||
{
|
||||
public static class LoggerFactory
|
||||
{
|
||||
public static Logger GetLogger()
|
||||
{
|
||||
return LogManager.Setup().LoadConfiguration(c =>
|
||||
{
|
||||
ColoredConsoleTarget consoleTarget = new ColoredConsoleTarget()
|
||||
{
|
||||
Layout = "${date}|${level:uppercase=true}|${message:withexception=true}"
|
||||
};
|
||||
FileTarget fileTarget = new FileTarget()
|
||||
{
|
||||
FileName = Environment.GetEnvironmentVariable("LOG_FILE_PATH"),
|
||||
Layout = "${date}|${level:uppercase=true}|${message:withexception=true}",
|
||||
Encoding = Encoding.UTF8,
|
||||
LineEnding = LineEndingMode.CRLF,
|
||||
KeepFileOpen = true,
|
||||
ConcurrentWrites = true,
|
||||
ArchiveAboveSize = long.Parse(Environment.GetEnvironmentVariable("LOG_FILE_SIZE")),
|
||||
MaxArchiveFiles = 10,
|
||||
MaxArchiveDays = 365
|
||||
};
|
||||
|
||||
_ = c.ForLogger("consoleAndFile")
|
||||
.FilterMinLevel(LogLevel.Debug)
|
||||
.WriteTo(consoleTarget)
|
||||
.WriteTo(fileTarget);
|
||||
}).GetLogger("consoleAndFile");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user