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

Upgrade/net.standard.2.0 #11

Merged
merged 5 commits into from Apr 13, 2018
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Change the message to also look at the rendered message

  • Loading branch information
SwankMotionPictures committed Aug 29, 2017
commit 12975434cabde03aa63ff6985d0e4de7996b175d
@@ -109,7 +109,16 @@ private string GetMessageAndObjectInfo(LoggingEvent loggingEvent, out object obj
objInfo = null;
var bytesLengthAllowedToLoggly = EVENT_SIZE;

if (loggingEvent.MessageObject != null)
if (!string.IsNullOrEmpty(loggingEvent.RenderedMessage))

This comment has been minimized.

@psamit

psamit Apr 12, 2018

Is this check specific for dot net core?
If yes then we should add a comment.

This comment has been minimized.

@Shwetajain148

Shwetajain148 Apr 12, 2018

I looked into the details and found the below for LogglyEvents.MessageObject property-
"Gets the message object used to initialize this event. Note that this event may not have a valid message object. If the event is serialized the message object will not be transferred. To get the text of the message the RenderedMessage property must be used not this property." from here.

I debugged the code here and could see that each time only the first if block was getting executed because we have the value in loggingEvent.RenderedMessage. The else block to check loggingEvent.MessageObject is not required anymore so I have removed it after ensuring.

And this is not specific to dot net core, it's a common use case for old .NET Frameworks too.

{
message = loggingEvent.RenderedMessage;
var messageSizeInBytes = Encoding.Default.GetByteCount(message);
if (messageSizeInBytes > bytesLengthAllowedToLoggly)
{
message = message.Substring(0, bytesLengthAllowedToLoggly);
}
}
else if (loggingEvent.MessageObject != null)
{
if (loggingEvent.MessageObject is string
//if it is sent by using InfoFormat method then treat it as a string message
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.