diff --git a/Libraries/SPTarkov.Server.Core/Utils/Logger/SptLogger.cs b/Libraries/SPTarkov.Server.Core/Utils/Logger/SptLogger.cs index 81017122..3028d08b 100644 --- a/Libraries/SPTarkov.Server.Core/Utils/Logger/SptLogger.cs +++ b/Libraries/SPTarkov.Server.Core/Utils/Logger/SptLogger.cs @@ -12,7 +12,8 @@ public class SptLogger : ISptLogger, IDisposable private readonly SptLoggerQueueManager _loggerQueueManager; private const string ConfigurationPath = "./sptLogger.json"; - private readonly SptLoggerConfiguration _config; + private const string ConfigurationPathDev = "./sptLogger.Development.json"; + private SptLoggerConfiguration _config; ~SptLogger() { @@ -24,13 +25,13 @@ public class SptLogger : ISptLogger, IDisposable _category = typeof(T).FullName; _loggerQueueManager = loggerQueueManager; - if (fileUtil.FileExists(ConfigurationPath)) + if (ProgramStatics.DEBUG()) { - _config = jsonUtil.DeserializeFromFile(ConfigurationPath); + LoadConfig(fileUtil, jsonUtil, ConfigurationPathDev); } else { - throw new Exception($"Unable to find SPTLogger file '{ConfigurationPath}'"); + LoadConfig(fileUtil, jsonUtil, ConfigurationPath); } if (_config == null) @@ -42,6 +43,18 @@ public class SptLogger : ISptLogger, IDisposable _loggerQueueManager.Initialize(_config); } + private void LoadConfig(FileUtil fileUtil, JsonUtil jsonUtil, string sptloggerDevelopmentJson) + { + if (fileUtil.FileExists(sptloggerDevelopmentJson)) + { + _config = jsonUtil.DeserializeFromFile(sptloggerDevelopmentJson); + } + else + { + throw new Exception($"Unable to find SPTLogger file '{sptloggerDevelopmentJson}'"); + } + } + public void OverrideCategory(string category) { _category = category; diff --git a/SPTarkov.Server/SPTarkov.Server.csproj b/SPTarkov.Server/SPTarkov.Server.csproj index f6188e94..9a0764bc 100644 --- a/SPTarkov.Server/SPTarkov.Server.csproj +++ b/SPTarkov.Server/SPTarkov.Server.csproj @@ -36,11 +36,12 @@ Always True - - Always + + Always + diff --git a/SPTarkov.Server/sptLogger.Development.json b/SPTarkov.Server/sptLogger.Development.json new file mode 100644 index 00000000..6d8cbb1c --- /dev/null +++ b/SPTarkov.Server/sptLogger.Development.json @@ -0,0 +1,71 @@ +{ + "loggers": [ + { + "type": "File", + "logLevel": "Trace", + "format": "[%date% %time%][%level%][%logger%] %message%", + "filePath": "./user/logs/kestrel/kestrel.txt", + "filters": [ + + { + "type": "Include", + "name": "Microsoft\\.AspNetCore\\.Server\\.Kestrel.*", + "matchingType": "Regex" + } + ] + }, + { + "type": "File", + "logLevel": "Trace", + "format": "[%date% %time%][%level%][%logger%] %message%", + "filePath": "./user/logs/spt/spt.txt", + "filters": [ + { + "type": "Exclude", + "name": ".*RequestLogger", + "matchingType": "Regex" + }, + { + "type": "Exclude", + "name": "Microsoft\\.AspNetCore\\.Server\\.Kestrel.*", + "matchingType": "Regex" + } + ] + }, + { + "type": "File", + "logLevel": "Trace", + "format": "[%date% %time%][%level%][%logger%] %message%", + "filePath": "./user/logs/requests/requests.txt", + "filters": [ + { + "type": "Include", + "name": ".*RequestLogger", + "matchingType": "Regex" + } + ] + }, + { + "type": "Console", + "logLevel": "Trace", + "format": "%message%", + "filters": [ + { + "type": "Exclude", + "name": "Microsoft.*", + "matchingType": "Regex" + }, + { + "type": "Exclude", + "name": ".*FileLogger", + "matchingType": "Regex" + }, + { + "type": "Exclude", + "name": ".*RequestLogger", + "matchingType": "Regex" + } + ] + } + ] +} diff --git a/SPTarkov.Server/sptLogger.json b/SPTarkov.Server/sptLogger.json index d44cf6c1..8d5b4094 100644 --- a/SPTarkov.Server/sptLogger.json +++ b/SPTarkov.Server/sptLogger.json @@ -33,7 +33,7 @@ }, { "type": "Console", - "logLevel": "Trace", + "logLevel": "Info", "format": "%message%", "filters": [ {