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

Nested JSON Layouts configured in NLog.config #1306

Closed
mccabela opened this issue Mar 17, 2016 · 2 comments
Closed

Nested JSON Layouts configured in NLog.config #1306

mccabela opened this issue Mar 17, 2016 · 2 comments

Comments

@mccabela
Copy link

Hi,

I'm trying to output my exception detail in a JSON structure with the config being done in the NLog.config.

At the moment the, in the example below, the exception is being rendered as a string.

I had a look at https://github.com/NLog/NLog/wiki/JsonLayout#advanced-examples which shows that it can be done, and an example of doing it using the API, and it does mention 'This is also possible with the XML config.' but there is no example and I cannot get it working.

If you could provide me with an example of Nested JSON Layouts configured in the NLog.config that would be great.

Many Thanks,

Lach

NLog version: 4.2.3

Platform: .Net 4.6.2

Current NLog config

    <target name="file" xsi:type="AsyncWrapper" queueLimit="5000" overflowAction="Discard">
      <target xsi:type="File" fileName="${logFilePath}web.txt"
              maxArchiveFiles="100"
              archiveNumbering="Sequence"
              archiveAboveSize="${archiveFileAboveBytes}"
              archiveFileName="${logFilePath}archive/web-{#####}.txt">
        <layout xsi:type="JsonLayout">
          <attribute name="datetime" layout="${iso8601dateformat}" />
          <attribute name="level" layout="${level:uppercase=true}" />
          <attribute name="logger" layout="${logger}" />
          <attribute name="thread" layout="${threadid}" />
          <attribute name="machine" layout="${machinename}" />
          <attribute name="message" layout="${message}" />

          <attribute name="exception" layout="${onexception:${exception:maxInnerExceptionLevel=5:innerFormat=tostring:format=tostring}}" />
        </layout>
      </target>
    </target>
@304NotModified 304NotModified self-assigned this Mar 17, 2016
@304NotModified
Copy link
Member

Hi, I have edit the wiki: https://github.com/NLog/NLog/wiki/JsonLayout

It is working as can be seen in #1309

Have fun with it :)

@304NotModified 304NotModified removed their assignment Mar 17, 2016
@mccabela
Copy link
Author

Thanks!

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

No branches or pull requests

2 participants