We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Hi, I had been trying to save a error trace to mongodb using NLog.Mongo using:
`
<extensions> <add assembly="NLog.Mongo"/> </extensions> <targets> <target name="file" xsi:type="File" layout="${longdate}|${level}|${processid}|${threadid}|${message} ${exception:format=tostring}" fileName="C:/TMC Applications/Logs/Traces/TraceLog.txt" archiveFileName="C:/TMC Applications/Logs/Traces/archives/TraceLog.{#####}.txt" archiveAboveSize="5242880" archiveNumbering="Sequence" concurrentWrites="true" keepFileOpen="true" encoding="iso-8859-2" /> <target name="mongo" xsi:type="Mongo" includeDefaults="false" connectionString="mongodb://localhost:27017/local" collectionName="traces" > <field name="date" layout="${event-properties:date}"/> <field name="applicationId" layout="${event-properties:applicationId}" /> <field name="moduleId" layout="${event-properties:moduleId}" /> <field name="userId" layout="${event-properties:item=userId}" /> <field name="logLevelId" layout="${event-properties:item=logLevelId}" /> <field name="browserInfo" layout="${event-properties:item=browserInfo}" /> <field name="ip" layout="${event-properties:item=ip}" /> <field name="hostName" layout="${event-properties:item=hostName}" /> <field name="screenInfo" layout="${event-properties:item=screenInfo}" /> <field name="errorCode" layout="${event-properties:item=errorCode}" /> <field name="callStack" layout="${event-properties:item=callStack}" /> <field name="description" layout="${event-properties:item=description}" /> </target> </targets> <rules> <logger name="*" minlevel="Info" writeTo="file" /> <logger name="*" minlevel="Info" writeTo="mongo"/> </rules>
adding properties with
`public void Save(Trace trace) { var logger = NLog.LogManager.GetCurrentClassLogger(); var traceJson = JsonConvert.SerializeObject(trace);
LogEventInfo info = new LogEventInfo(LogLevel.Warn, "NLogger", traceJson); info.Properties.Add("date", trace.Date); info.Properties.Add("applicationId", trace.ApplicationId); info.Properties.Add("moduleId", trace.ModuleId); info.Properties.Add("userId", trace.UserId); info.Properties.Add("logLevelId", trace.LogLevelId); info.Properties.Add("browserInfo", trace.BrowserInfo); info.Properties.Add("ip", trace.Ip); info.Properties.Add("hostName", trace.HostName); info.Properties.Add("screenInfo", trace.ScreenInfo); info.Properties.Add("errorCode", trace.ErrorCode); info.Properties.Add("callStack", trace.CallStack); info.Properties.Add("description", trace.Description); logger.Log(info); }`
But receiving this in mongodb database: Is there a way to remove the last properties object from the json in Mongo?
Thanks!
The text was updated successfully, but these errors were encountered:
Hi Use IncludeEventProperties = false in the config. [Like: <target IncludeEventProperties = false ]
Sorry, something went wrong.
Hi, thanks for the reply. I already tried with IncludeEventProperties = false but it didnt work. I ended up making a customTarget. Thanks again
No branches or pull requests
Hi,
I had been trying to save a error trace to mongodb using NLog.Mongo using:
`
`
adding properties with
`public void Save(Trace trace)
{
var logger = NLog.LogManager.GetCurrentClassLogger();
var traceJson = JsonConvert.SerializeObject(trace);
But receiving this in mongodb database:
Is there a way to remove the last properties object from the json in Mongo?
Thanks!
The text was updated successfully, but these errors were encountered: