diff options
| author | Bond_009 <bond.009@outlook.com> | 2018-12-14 23:34:53 +0100 |
|---|---|---|
| committer | Bond_009 <bond.009@outlook.com> | 2018-12-30 22:44:38 +0100 |
| commit | 6d9ee138d6191ba33ec77b28cbc3543d59770e67 (patch) | |
| tree | 1cb69c4ef0b3e3119418c01bd9fa7b3586a02854 /MediaBrowser.Server.Mono/Program.cs | |
| parent | a51798dd8d1fe71357c7926e9657f2c67cd40ed7 (diff) | |
More log dir configurable
Diffstat (limited to 'MediaBrowser.Server.Mono/Program.cs')
| -rw-r--r-- | MediaBrowser.Server.Mono/Program.cs | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/MediaBrowser.Server.Mono/Program.cs b/MediaBrowser.Server.Mono/Program.cs index 1e47322f1..32953e89d 100644 --- a/MediaBrowser.Server.Mono/Program.cs +++ b/MediaBrowser.Server.Mono/Program.cs @@ -154,8 +154,13 @@ namespace MediaBrowser.Server.Mono } } - private static async Task createLogger() + private static void createLogger() { + var logDir = Environment.GetEnvironmentVariable("JELLYFIN_LOG_DIR"); + if (string.IsNullOrEmpty(logDir)){ + logDir = Path.Combine(_appPaths.ProgramDataPath, "logs"); + Environment.SetEnvironmentVariable("JELLYFIN_LOG_DIR", logDir); + } try { string path = Path.Combine(_appPaths.ProgramDataPath, "logging.json"); @@ -168,11 +173,13 @@ namespace MediaBrowser.Server.Mono using (Stream rscstr = assembly.GetManifestResourceStream(resourcePath)) using (Stream fstr = File.Open(path, FileMode.CreateNew)) { - await rscstr.CopyToAsync(fstr); + rscstr.CopyTo(fstr); } } var configuration = new ConfigurationBuilder() - .AddJsonFile(path) + .SetBasePath(_appPaths.ProgramDataPath) + .AddJsonFile("logging.json") + .AddEnvironmentVariables("JELLYFIN_") .Build(); Serilog.Log.Logger = new LoggerConfiguration() @@ -185,7 +192,7 @@ namespace MediaBrowser.Server.Mono Serilog.Log.Logger = new LoggerConfiguration() .WriteTo.Console(outputTemplate: "[{Timestamp:HH:mm:ss}] [{Level:u3}] {Message:lj}{NewLine}{Exception}") .WriteTo.File( - Path.Combine(AppContext.BaseDirectory, "logs", "log_.log"), + Path.Combine(logDir, "logs", "log_.log"), rollingInterval: RollingInterval.Day, outputTemplate: "[{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz}] [{Level:u3}] {Message}{NewLine}{Exception}") .Enrich.FromLogContext() |
