I'm changing NLog.config file for UiPath. I want to increase truncate value to 20000 and I've tried following syntax but it's not working.
<variable name="truncated_message" value="${replace:replaceWith=...TRUNCATED:regex=true:inner=${message}:searchFor=^[\s\S]{20000}}"/>
<target type="File" name="WorkflowLogFiles" fileName="${WorkflowLoggingDirectory}/${shortdate}_Execution.log" layout="${time} ${level} ${truncated_message}" keepFileOpen="true" openFileCacheTimeout="5" concurrentWrites="true" encoding="utf-8" writeBom="true" />
I've also tried following regex but they do not work for me
(^(?:\S+\s+\n?){0, 20000})
(?\=.\{20000\}).+
Can anyone please tell me what am I doing wrong and how to do set the truncate value to 20000?
This works for me:
<nlog>
<variable name="truncated_message_new" value="${message:truncate=20000}" />
<variable name="truncated_message_old" value="${trim-whitespace:inner=${message:padding=-20000:fixedLength=true}}" />
<targets>
<target type="File" name="WorkflowLogFiles" fileName="C:\temp\nlog/${shortdate}_Execution.log" layout="${time} ${level} ${truncated_message_old}" keepFileOpen="true" openFileCacheTimeout="5" concurrentWrites="true" encoding="utf-8" writeBom="true" />
</targets>
<rules>
<logger name="*" minlevel="Trace" writeTo="WorkflowLogFiles" />
</rules>
</nlog>
It only saves 20000 characters:
var test = string.Empty.PadLeft(40000, '*');
NLog.LogManager.GetLogger("test").Info("Doing hard work! {Action}", test);