My rules are being ignored when a assembly namespace is specified #1895

Open
jcbremond opened this Issue Jan 10, 2017 · 3 comments

Projects

None yet

3 participants

@jcbremond
jcbremond commented Jan 10, 2017 edited

- Question/Bug ?

NLog version: 4.4.1
Platform: .Net 4.5

Current NLog config (xml or C#, if relevant)

 <rules>
    <!--Skip Microsoft logs and so log only own logs-->
    <logger name="Microsoft.*" minlevel="Trace" writeTo="blackhole" final="true" />

    <!-- disabled rules for debug (namespace pb ) -->
    <logger name="*" minlevel="Warn" writeTo="asyncFile" enabled="false" />
    <logger name="*" minlevel="Debug" writeTo="asyncFile,elasticSearch" enabled="false"  />
    <logger name="*" minlevel="Info" maxlevel="Info" writeTo="consoleColor,elasticSearchCustom" enabled="false" />
 <!-- rules for log only for 

NLog - Copie.config.txt

specific assembly:

    <logger name="Test.Dummy.*" minlevel="Info" maxlevel="Info" writeTo="consoleColor" enabled="true" />
    
  </rules>

If you take a look at my rules:

  <logger name="Test.Dummy.*" minlevel="Info" maxlevel="Info" writeTo="consoleColor" enabled="true" />

i need log only for an specific assembly but i doesn't log if logger name is not "*" why ?
exemple : ConsoleTestNlog.zip

Thank's in advance for your reply.
Jc.

@304NotModified
Member
304NotModified commented Jan 10, 2017 edited

hey!

This is a common mistake. Could you try to log ${logger} in the target to double check the loggername?

e.g.

    <target name="console" xsi:type="Console" message="${logger}: ${message}" />
@jcbremond

When i add "message="${logger}: ${message}" " in my target an exception occurs in my demo app...

Visual Studio 2015 does not like this addition ...

capturenlog1

What to do ?

TIA.
Jc

ps : Sorry for my poor English :-)

@304NotModified
Member

sorry meant layout
So:

<target name="console" xsi:type="Console" layout="${logger}: ${message}" />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment