How to escape newline characters in the message?
问题 I'm using log4net with FileAppender. The layout pattern is "%utcdate %message%newline" , so every message takes 1 line. However, there is an issue with messages containing new line chars; is it possible to escape new lines before writing to the file? 回答1: You can create a custom PatternConverter which escapes the newline characters. This provides a more flexible solution than the other answer because you can use it with any appender. I followed these articles to implement a custom