prueba logs
This commit is contained in:
parent
6335ff42e0
commit
f62bb133c5
2 changed files with 118 additions and 74 deletions
|
@ -8,12 +8,26 @@ namespace Shared.Helper
|
|||
{
|
||||
public static void ConfigureLogger(IConfiguration configuration)
|
||||
{
|
||||
var logFilePath = configuration.GetSection("Logging:LogFile:Path").Value ?? "";
|
||||
var logFileFullPath = Path.Combine(Directory.GetCurrentDirectory(), logFilePath);
|
||||
var logFilePath = configuration.GetSection("Logging:LogFile:Path").Value ?? "logs/log-.txt";
|
||||
|
||||
var exePath = AppContext.BaseDirectory;
|
||||
var logFileFullPath = Path.Combine(exePath, logFilePath);
|
||||
|
||||
var logDirectory = Path.GetDirectoryName(logFileFullPath);
|
||||
if (!string.IsNullOrEmpty(logDirectory))
|
||||
{
|
||||
Directory.CreateDirectory(logDirectory);
|
||||
}
|
||||
|
||||
Log.Logger = new LoggerConfiguration()
|
||||
.ReadFrom.Configuration(configuration)
|
||||
.WriteTo.File(logFileFullPath, rollingInterval: RollingInterval.Day)
|
||||
.WriteTo.File(
|
||||
path: logFileFullPath,
|
||||
rollingInterval: RollingInterval.Day,
|
||||
shared: true,
|
||||
retainedFileCountLimit: 30,
|
||||
outputTemplate: "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] {Message:lj}{NewLine}{Exception}"
|
||||
)
|
||||
.CreateLogger();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue