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

NLogLoggingConfiguration - Add support for config variables with JsonLayout #465

Merged
merged 1 commit into from
Aug 26, 2021

Conversation

snakefoot
Copy link
Contributor

@snakefoot snakefoot commented Jan 6, 2021

Then one can do like this with NLog 5.0 (See also NLog/NLog#3459)

{
    "NLog": {
        "throwConfigExceptions": true,
        "variables": {
            "myJson": {
                "type": "JsonLayout",
                "Attributes": [
                    { "name": "short_date", "layout": "${shortdate}" },
                    { "name": "message", "layout": "${message" }
                ]
            }
        },
        "targets": {
            "console": {
                "type": "Console",
                "layout": "${var:myJson}"
            }
        },
        "rules": [
            {
                "logger": "*",
                "minLevel": "Trace",
                "writeTo": "Console"
            }
        ]
    }
}

So the console gives output like this:

{ "short_date": "2021-01-06", "message": "Doing hard work! \"Action1\"" }
{ "short_date": "2021-01-06", "message": "Doing hard work! \"Action1\"" }

@snakefoot
Copy link
Contributor Author

Guess an unit-test can be created when NLog 5.0 becomes RTM.

@MeirAtWork
Copy link

hi guys. this work is awesome. can this be merged and released as a new Nuget package? I need this feature. thanks for your great work!

@snakefoot
Copy link
Contributor Author

@MeirAtWork Will be merged when NLog 5.0 is ready as release-candidate.

@MeirAtWork
Copy link

MeirAtWork commented Feb 14, 2021

thanks! any time frame ?

@snakefoot
Copy link
Contributor Author

Depends on how fast the todo-list is completed: NLog/NLog#4274 (Include link to release-docs)

Hopefully the NLog 5.0 RC1 will be ready within one or two weeks. Then depending on feedback, then it might delay the final release

@304NotModified 304NotModified added this to the 2.0 milestone Feb 25, 2021
@snakefoot snakefoot changed the title NLogLoggingConfiguration - Add support for config variables with JsonLayout NLogLoggingConfiguration - Add support for config variables with JsonLayout (WIP) Feb 28, 2021
@teian
Copy link

teian commented Aug 19, 2021

Can we maybe get this into 4.x since 5.x seems to take a while longer?

@snakefoot
Copy link
Contributor Author

@teian Can we maybe get this into 4.x since 5.x seems to take a while longer?

It depends on NLog 5.0 being released, as it change Config-Variables from SimpleLayout to Layout

@teian
Copy link

teian commented Aug 20, 2021

Ah okay, thanks for the clarification!

@snakefoot snakefoot changed the title NLogLoggingConfiguration - Add support for config variables with JsonLayout (WIP) NLogLoggingConfiguration - Add support for config variables with JsonLayout Aug 26, 2021
@snakefoot snakefoot merged commit 5aa3c2d into NLog:master Aug 26, 2021
@snakefoot
Copy link
Contributor Author

snakefoot commented Aug 29, 2021

NLog.Extensions.Logging ver. 5.0.0-preview.1 has been released. See also: NLog 5.0 Preview-1 ready for release testing

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

Successfully merging this pull request may close these issues.

None yet

4 participants