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

Log4netTextFormatter does not escape message containing XML #51

Closed
mkb137 opened this issue Jul 4, 2019 · 7 comments · Fixed by #52
Closed

Log4netTextFormatter does not escape message containing XML #51

mkb137 opened this issue Jul 4, 2019 · 7 comments · Fixed by #52
Labels

Comments

@mkb137
Copy link

mkb137 commented Jul 4, 2019

Describe the bug
The Log4netTextFormatter does not escape a log message containing XML special characters. For example,

Log.Debug( "Do<Something>")

will result in XML like:

<log4net:message>Do<Something></log4net:message>

Tools attempting to parse the XML will fail.

Expected behavior
The XML should be escaped, as in:

<log4net:message>Do&lt;Something&gt;</log4net:message>

Additional context
I'm using a customized version of Sentinel as the log reader (https://github.com/mkb137/Sentinel)

@mkb137 mkb137 added the bug label Jul 4, 2019
@FantasticFiasco
Copy link
Owner

Thanks! I'll look into this tonight, but I am currently on holiday and won't probably release a new version until the weekend. Will you be able to work around the issue?

@mkb137
Copy link
Author

mkb137 commented Jul 4, 2019

Yes, no problem.

FantasticFiasco added a commit that referenced this issue Jul 5, 2019
Correctly XML escape exception all properties serialized by
`Log4jTextFormatter` and `Log4netTextFormatter`.

Closes #51
FantasticFiasco added a commit that referenced this issue Jul 7, 2019
Correctly XML escape all properties serialized by
`Log4jTextFormatter` and `Log4netTextFormatter`.

Closes #51
FantasticFiasco added a commit that referenced this issue Jul 7, 2019
Correctly XML escape all properties serialized by
`Log4jTextFormatter` and `Log4netTextFormatter`.

Closes #51
@FantasticFiasco
Copy link
Owner

There is a new pre-release available on www.nuget.org, with a fix for your issue.

Would you be able to validate that the pre-release works as you'd expect? You will have to make some changes to your configuration of the UDP sink, please see the migration instructions here.

@mkb137
Copy link
Author

mkb137 commented Jul 7, 2019

I tried it and confirmed that it works.

FantasticFiasco added a commit that referenced this issue Jul 8, 2019
Closes #42
Closes #45
Closes #51
@FantasticFiasco
Copy link
Owner

Release v6.0.0 is now live on nuget.org.

Thank you for reporting the issue!

@mkb137
Copy link
Author

mkb137 commented Jul 8, 2019

If you want to add it to your documentation, this is how you configure the sink in app.config settings:

		<add key="serilog:using:Udp" value="Serilog.Sinks.Udp" />
		<add key="serilog:write-to:Udp"/>
		<add key="serilog:write-to:Udp.remoteAddress" value="127.0.0.1"/>
		<add key="serilog:write-to:Udp.remotePort" value="9998"/>
		<add key="serilog:write-to:Udp.family" value="InterNetwork"/>
		<add key="serilog:write-to:Udp.formatter" value="Serilog.Sinks.Udp.TextFormatters.Log4netTextFormatter, Serilog.Sinks.Udp, Version=6.0.0.0, Culture=neutral, PublicKeyToken=24c2f752a8e58a10"/>

@FantasticFiasco
Copy link
Owner

Thanks! I've updated the readme with your provided configuration.

Best wishes to you on your coding journey!

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

Successfully merging a pull request may close this issue.

2 participants