-
-
Notifications
You must be signed in to change notification settings - Fork 330
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🔧 centralize log path creation and improve logging (#2385)
- change the rolling interval on the main log to hourly, and to rollOnFileSizeLimit - change the rolling interval on the error log to daily - Added the log path to the output, beginning and end.
- Loading branch information
Showing
4 changed files
with
55 additions
and
26 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Reflection; | ||
using System.Text; | ||
|
||
namespace MigrationTools.Services | ||
{ | ||
public class LogLocationService | ||
{ | ||
private static string logDate = DateTime.Now.ToString("yyyyMMddHHmmss"); | ||
|
||
|
||
private static string _logsPath = CreateLogsPath(); | ||
|
||
public static string GetLogPath() | ||
{ | ||
// Check if the string has been generated. | ||
if (_logsPath == null) | ||
{ | ||
// Generate the string at runtime (e.g., any custom logic). | ||
_logsPath = CreateLogsPath(); | ||
} | ||
|
||
// Return the _logsPath string. | ||
return _logsPath; | ||
} | ||
|
||
private static string CreateLogsPath() | ||
{ | ||
string exportPath; | ||
string assPath = Assembly.GetEntryAssembly().Location; | ||
exportPath = Path.Combine(Path.GetDirectoryName(assPath), "logs", logDate); | ||
if (!Directory.Exists(exportPath)) | ||
{ | ||
Directory.CreateDirectory(exportPath); | ||
} | ||
|
||
return exportPath; | ||
} | ||
} | ||
} |