Skip to content

Changed the UTF Encoding instance to avoid inserting the BOM character #10

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

Merged
merged 2 commits into from
Jul 28, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/Serilog.Sinks.File/Sinks/File/FileSink.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// limitations under the License.

using System;
using System.IO;
using System.IO;
using System.Text;
using Serilog.Core;
using Serilog.Debugging;
Expand Down Expand Up @@ -56,7 +56,7 @@ public FileSink(string path, ITextFormatter textFormatter, long? fileSizeLimitBy
TryCreateDirectory(path);

var file = System.IO.File.Open(path, FileMode.Append, FileAccess.Write, FileShare.Read);
var outputWriter = new StreamWriter(file, encoding ?? Encoding.UTF8);
var outputWriter = new StreamWriter(file, encoding ?? new UTF8Encoding(encoderShouldEmitUTF8Identifier: false));
if (fileSizeLimitBytes != null)
{
var initialBytes = file.Length;
Expand Down Expand Up @@ -106,4 +106,4 @@ public void Emit(LogEvent logEvent)
/// </summary>
public void Dispose() => _output.Dispose();
}
}
}
3 changes: 2 additions & 1 deletion src/Serilog.Sinks.File/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
"dependencies": {
"System.IO": "4.1.0",
"System.IO.FileSystem": "4.0.1",
"System.IO.FileSystem.Primitives": "4.0.1"
"System.IO.FileSystem.Primitives": "4.0.1",
"System.Text.Encoding.Extensions": "4.0.11"
}
}
}
Expand Down