/// <summary> /// Initializes a new instance of the <see cref="RockSerilogReader"/> class. /// </summary> /// <param name="logger">The logger.</param> public RockSerilogReader(IRockLogger logger) { _rockLogger = logger; _jsonSerializer = JsonSerializer.Create(new JsonSerializerSettings { DateParseHandling = DateParseHandling.None, Culture = CultureInfo.InvariantCulture }); }
private void CreateLogFiles(IRockLogger logger, int maxFilesizeInMB, int numberOfFiles) { var maxByteCount = maxFilesizeInMB * 1024 * 1024 * numberOfFiles; var currentByteCount = 0; var logHeaderInformation = "0000-00-00 00:00:00.000 -00:00 [INF] OTHER"; while (currentByteCount < maxByteCount) { var expectedLogMessage = $"Test - {Guid.NewGuid()}"; logger.Information(expectedLogMessage); currentByteCount += Encoding.ASCII.GetByteCount($"{logHeaderInformation} {expectedLogMessage}"); } TestContext.WriteLine("CreateLogFiles wrote {0} bytes of logs to {1}.", currentByteCount, logger.LogConfiguration.LogPath); }
/// <summary> /// Initializes a new instance of the <see cref="RockSerilogReader"/> class. /// </summary> /// <param name="logger">The logger.</param> public RockSerilogReader(IRockLogger logger) { rockLogger = logger; rockLogDirectory = System.IO.Path.GetFullPath(System.IO.Path.GetDirectoryName(rockLogger.LogConfiguration.LogPath)); searchPattern = System.IO.Path.GetFileNameWithoutExtension(rockLogger.LogConfiguration.LogPath); searchPattern += "*"; searchPattern += System.IO.Path.GetExtension(rockLogger.LogConfiguration.LogPath); jsonSerializer = JsonSerializer.Create(new JsonSerializerSettings { DateParseHandling = DateParseHandling.None, Culture = CultureInfo.InvariantCulture }); }
private List <string> CreateLogFiles(IRockLogger logger) { var maxByteCount = logger.LogConfiguration.MaxFileSize * 1024 * 1024 * (logger.LogConfiguration.NumberOfLogFiles - 1); var currentByteCount = 0; var logRecordSize = Encoding.ASCII.GetByteCount("{\"@t\":\"0000-00-00T00:00:00.0000000Z\",\"@mt\":\"{domain} Test - 00000000-0000-0000-0000-000000000000\",\"domain\":\"OTHER\"}"); var expectedLogs = new List <string>(); while (currentByteCount < maxByteCount) { var guid = Guid.NewGuid(); var expectedLogMessage = $"Test - {guid}"; logger.Information(RockLogDomains.Other, expectedLogMessage); expectedLogs.Add(guid.ToString()); currentByteCount += logRecordSize; } return(expectedLogs); }