Admiral Land
Admiral Land

Reputation: 2492

Nlog: how to write logger without namespace?

I try to modify my nlog confile file - how it looks like this:

layout="${longdate}|${uppercase:${level}}|${logger}|version:${appVersion}|${message:withexception=true}"

And in logs looks like:

2023-01-12 13:34:20.7639|0|INFO|Some.My.Namespace.App.MyService|version:1.0.30.0|some text

How to make string like:

2023-01-12 13:34:20.7639|0|INFO|MyService|version:1.0.30.0|some text

Is it possible to do?

Can you help me? Thank you!

Upvotes: 2

Views: 382

Answers (1)

Admiral Land
Admiral Land

Reputation: 2492

I found this:

layout="${longdate}|${uppercase:${level}}|${logger:shortName=true}|version:${appVersion}|${message:withexception=true}"/>

Main thing:

${logger:shortName=true}

2023-01-12 13:34:20.7639|0|INFO|MyService|version:1.0.30.0|some text

See also: https://github.com/NLog/NLog/wiki/Logger-Layout-Renderer

Upvotes: 6

Related Questions