Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Buffered events upload on logger dispose fails if there is no logs yet #198

Open
MaceWindu opened this issue Apr 13, 2023 · 1 comment
Open

Comments

@MaceWindu
Copy link

using Serilog;
using Serilog.Debugging;

internal class Program
{
	static void Main()
	{
		using var logger = new LoggerConfiguration()
			.WriteTo.Seq("http://localhost:5341", bufferBaseFilename: @"<PATH_TO_NOT_YET_CREATED_FOLDER>\logfile")
			.CreateLogger();

		// buffer folder will be created on first log write
		//logger.Information("Create bookmarks folder");

		SelfLog.Enable(msg => logger.Error($"Logger failure: {msg}"));

		// on logger dispose we try to upload buffered data and fail with
		// DirectoryNotFoundException: Could not find a part of the path 'PATH_TO_NOT_YET_CREATED_FOLDER\\logfile.bookmark'
	}
}
Exception while emitting periodic batch from Serilog.Sinks.Seq.Durable.HttpLogShipper: System.IO.DirectoryNotFoundException: Could not find a part of the path '<PATH_TO_NOT_YET_CREATED_FOLDER>\\logfile.bookmark'.
   at Microsoft.Win32.SafeHandles.SafeFileHandle.CreateFile(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options)
   at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, Nullable`1 unixCreateMode)
   at System.IO.Strategies.OSFileStreamStrategy..ctor(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, Nullable`1 unixCreateMode)
   at System.IO.Strategies.FileStreamHelpers.ChooseStrategyCore(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, Nullable`1 unixCreateMode)
   at System.IO.File.Open(String path, FileMode mode, FileAccess access, FileShare share)
   at Serilog.Sinks.Seq.Durable.BookmarkFile..ctor(String bookmarkFilename)
   at Serilog.Sinks.Seq.Durable.FileSet.OpenBookmarkFile()
   at Serilog.Sinks.Seq.Durable.HttpLogShipper.OnTick()
@todthomson
Copy link

Looks like a bug @MaceWindu. Thanks for the bug report. We'll take a look asap and report back.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants