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

"Invalid Token" using NLog.Mongo in .Net Core #70

Open
jairosoftjay opened this issue Jul 2, 2021 · 3 comments
Open

"Invalid Token" using NLog.Mongo in .Net Core #70

jairosoftjay opened this issue Jul 2, 2021 · 3 comments

Comments

@jairosoftjay
Copy link

Upon using the NLog.Mongo in .Net Core Class Library and use it as a reference in a console app it returns the "Invalid Token".
The solution is just the same as what you can see here in the Console test App and setup is just the same.
But when you use this in a .Net Framework Class Library it returns fine.
image

@jairosoftjay jairosoftjay changed the title "Invalid Token" using NLog.Mongo "Invalid Token" using NLog.Mongo in .Net Core Jul 2, 2021
@snakefoot
Copy link
Contributor

"Invalid Token" is returned from MongoDb. Do you have an NLog.config or other example of how you configure the NLog Target?

Have you checked the NLog InternalLogger for clues?

@jairosoftjay
Copy link
Author

jairosoftjay commented Jul 5, 2021

@snakefoot
I generate the log using the internal logging please see the generated log below:
image

Also below is the sample Nlog.config that is being used:

<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      autoReload="true"
      throwExceptions="true"
      internalLogLevel="Trace" internalLogFile="c:\temp\nlog-internal.log">

  <!-- enable  mongodb layout renderers -->
  <extensions>
    <add assembly="NLog.WindowsIdentity"/>
    <add assembly="NLog.Mongo"/>
  </extensions>

  <targets>
    <!-- write log to mongodb-->
    <target xsi:type="Mongo"
          name="mongo" databaseName="TestLog"
          collectionName="Logs"
          connectionString="mongodb://localhost/TestLog"
          IncludeDefaults="false"
          >
      <Field name="LongDate" layout="${longdate}" bsonType="DateTime" />
      <Field name="Level" layout="${level}" />
      <Field name="Logger" layout="${logger}"/>
      <Field name="Message" layout="${message}" />
      <Field name="Exception" layout="${exception:format=tostring}" />
      <Field name="CallSite" layout="${callsite:filename=true}"/>
      <Field name="StackTrace" layout="${stacktrace}"/>
    </target>

  </targets>

  <rules>
    <!-- add your logging rules here -->
    <logger name="*" minlevel="Trace" writeTo="mongo"/>
  </rules>
</nlog>

@snakefoot
Copy link
Contributor

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

No branches or pull requests

2 participants