Added dev and prod files for logger
This commit is contained in:
@@ -12,7 +12,8 @@ public class SptLogger<T> : ISptLogger<T>, 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<T> : ISptLogger<T>, IDisposable
|
||||
_category = typeof(T).FullName;
|
||||
_loggerQueueManager = loggerQueueManager;
|
||||
|
||||
if (fileUtil.FileExists(ConfigurationPath))
|
||||
if (ProgramStatics.DEBUG())
|
||||
{
|
||||
_config = jsonUtil.DeserializeFromFile<SptLoggerConfiguration>(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<T> : ISptLogger<T>, IDisposable
|
||||
_loggerQueueManager.Initialize(_config);
|
||||
}
|
||||
|
||||
private void LoadConfig(FileUtil fileUtil, JsonUtil jsonUtil, string sptloggerDevelopmentJson)
|
||||
{
|
||||
if (fileUtil.FileExists(sptloggerDevelopmentJson))
|
||||
{
|
||||
_config = jsonUtil.DeserializeFromFile<SptLoggerConfiguration>(sptloggerDevelopmentJson);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception($"Unable to find SPTLogger file '{sptloggerDevelopmentJson}'");
|
||||
}
|
||||
}
|
||||
|
||||
public void OverrideCategory(string category)
|
||||
{
|
||||
_category = category;
|
||||
|
||||
@@ -36,11 +36,12 @@
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
<ExcludeFromSingleFile>True</ExcludeFromSingleFile>
|
||||
</Content>
|
||||
<None Remove="appsettings.json"/>
|
||||
<None Remove="appsettings.Development.json"/>
|
||||
<None Update="sptLogger.json">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="sptLogger.Development.json">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -33,7 +33,7 @@
|
||||
},
|
||||
{
|
||||
"type": "Console",
|
||||
"logLevel": "Trace",
|
||||
"logLevel": "Info",
|
||||
"format": "%message%",
|
||||
"filters": [
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user