Serilog controlling output format for file sink
up vote
0
down vote
favorite
So let me just give a bit of context here we use Serilog and we use various sinks including some of our own ones.
For most of the sinks we add extra properties that we need to use to drive logic, such as routing/filtering etc etc
So for us a given log statement may look something like this
public class SomeClass
{
public String Name { get; set; }
public string AppType { get; set; }
}
var loggingEnvironment = new SomeClass()
{
Name = "foo",
AppType = "test",
};
Logger.Error("{Category} {Message} {@LoggingEnvironment}", LogCategory.BUS, "Oh no its gone bad jim", loggingEnvironment);
Where we need the LoggingEnvironment property to travel all the way through MOST of our sinks.
However for the file Sink output we see if this
2018-11-21 10:30:21.332 [ERR] BUS "Oh no its gone bad jim" SomeClass { Name: "foo", AppType: "test" }
What we would like the file written text to be its just
2018-11-21 10:30:21.332 [ERR] BUS "Oh no its gone bad jim"
Reading more into this section from Serilog https://github.com/serilog/serilog/wiki/Formatting-Output it talks about the formatters for Message.
Message - The log event's message, rendered as plain text. The :l format specifier switches of quoting of strings, and :j uses JSON-style rendering for any embedded structured data.
But as this extra property is not really part of the message, I don't think that section of the docs applies.
Short of bringing in all the code for the Serilog.Sinks.File into our own codebase, is there a way to get to rid of this (or any other property) value from being written to a sink output?
serilog
add a comment |
up vote
0
down vote
favorite
So let me just give a bit of context here we use Serilog and we use various sinks including some of our own ones.
For most of the sinks we add extra properties that we need to use to drive logic, such as routing/filtering etc etc
So for us a given log statement may look something like this
public class SomeClass
{
public String Name { get; set; }
public string AppType { get; set; }
}
var loggingEnvironment = new SomeClass()
{
Name = "foo",
AppType = "test",
};
Logger.Error("{Category} {Message} {@LoggingEnvironment}", LogCategory.BUS, "Oh no its gone bad jim", loggingEnvironment);
Where we need the LoggingEnvironment property to travel all the way through MOST of our sinks.
However for the file Sink output we see if this
2018-11-21 10:30:21.332 [ERR] BUS "Oh no its gone bad jim" SomeClass { Name: "foo", AppType: "test" }
What we would like the file written text to be its just
2018-11-21 10:30:21.332 [ERR] BUS "Oh no its gone bad jim"
Reading more into this section from Serilog https://github.com/serilog/serilog/wiki/Formatting-Output it talks about the formatters for Message.
Message - The log event's message, rendered as plain text. The :l format specifier switches of quoting of strings, and :j uses JSON-style rendering for any embedded structured data.
But as this extra property is not really part of the message, I don't think that section of the docs applies.
Short of bringing in all the code for the Serilog.Sinks.File into our own codebase, is there a way to get to rid of this (or any other property) value from being written to a sink output?
serilog
So apparently an enricher property is the way to do this stackoverflow.com/questions/30637416/… which will be a property but not in the main message template
– sacha
2 days ago
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
So let me just give a bit of context here we use Serilog and we use various sinks including some of our own ones.
For most of the sinks we add extra properties that we need to use to drive logic, such as routing/filtering etc etc
So for us a given log statement may look something like this
public class SomeClass
{
public String Name { get; set; }
public string AppType { get; set; }
}
var loggingEnvironment = new SomeClass()
{
Name = "foo",
AppType = "test",
};
Logger.Error("{Category} {Message} {@LoggingEnvironment}", LogCategory.BUS, "Oh no its gone bad jim", loggingEnvironment);
Where we need the LoggingEnvironment property to travel all the way through MOST of our sinks.
However for the file Sink output we see if this
2018-11-21 10:30:21.332 [ERR] BUS "Oh no its gone bad jim" SomeClass { Name: "foo", AppType: "test" }
What we would like the file written text to be its just
2018-11-21 10:30:21.332 [ERR] BUS "Oh no its gone bad jim"
Reading more into this section from Serilog https://github.com/serilog/serilog/wiki/Formatting-Output it talks about the formatters for Message.
Message - The log event's message, rendered as plain text. The :l format specifier switches of quoting of strings, and :j uses JSON-style rendering for any embedded structured data.
But as this extra property is not really part of the message, I don't think that section of the docs applies.
Short of bringing in all the code for the Serilog.Sinks.File into our own codebase, is there a way to get to rid of this (or any other property) value from being written to a sink output?
serilog
So let me just give a bit of context here we use Serilog and we use various sinks including some of our own ones.
For most of the sinks we add extra properties that we need to use to drive logic, such as routing/filtering etc etc
So for us a given log statement may look something like this
public class SomeClass
{
public String Name { get; set; }
public string AppType { get; set; }
}
var loggingEnvironment = new SomeClass()
{
Name = "foo",
AppType = "test",
};
Logger.Error("{Category} {Message} {@LoggingEnvironment}", LogCategory.BUS, "Oh no its gone bad jim", loggingEnvironment);
Where we need the LoggingEnvironment property to travel all the way through MOST of our sinks.
However for the file Sink output we see if this
2018-11-21 10:30:21.332 [ERR] BUS "Oh no its gone bad jim" SomeClass { Name: "foo", AppType: "test" }
What we would like the file written text to be its just
2018-11-21 10:30:21.332 [ERR] BUS "Oh no its gone bad jim"
Reading more into this section from Serilog https://github.com/serilog/serilog/wiki/Formatting-Output it talks about the formatters for Message.
Message - The log event's message, rendered as plain text. The :l format specifier switches of quoting of strings, and :j uses JSON-style rendering for any embedded structured data.
But as this extra property is not really part of the message, I don't think that section of the docs applies.
Short of bringing in all the code for the Serilog.Sinks.File into our own codebase, is there a way to get to rid of this (or any other property) value from being written to a sink output?
serilog
serilog
asked 2 days ago
sacha
953918
953918
So apparently an enricher property is the way to do this stackoverflow.com/questions/30637416/… which will be a property but not in the main message template
– sacha
2 days ago
add a comment |
So apparently an enricher property is the way to do this stackoverflow.com/questions/30637416/… which will be a property but not in the main message template
– sacha
2 days ago
So apparently an enricher property is the way to do this stackoverflow.com/questions/30637416/… which will be a property but not in the main message template
– sacha
2 days ago
So apparently an enricher property is the way to do this stackoverflow.com/questions/30637416/… which will be a property but not in the main message template
– sacha
2 days ago
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53410176%2fserilog-controlling-output-format-for-file-sink%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
So apparently an enricher property is the way to do this stackoverflow.com/questions/30637416/… which will be a property but not in the main message template
– sacha
2 days ago