Add generic listener for TraceSources without config file

I want to redirect registration from System.Net to NLog:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.diagnostics>
    <sources>
      <source name="System.Net" switchValue="All">
        <listeners>
          <add name="nlog" />
        </listeners>
      </source>
      <source name="System.Net.Sockets" switchValue="All">
        <listeners>
          <add name="nlog" />
        </listeners>
      </source>
    </sources>
    <sharedListeners>
      <add name="nlog" type="NLog.NLogTraceListener, NLog" />
    </sharedListeners>
  </system.diagnostics>
</configuration>

      

How can I get it to work with code without app.config / web.config files? I cannot use them in Unity3D.

+3
c # logging unity3d system.diagnostics nlog


source to share


No one has answered this question yet

See similar questions:

ten
System.Net (HttpWebRequest) tracing without using files or app.config?

or similar:

1032
Ukkonen Suffix Tree Algorithm in Plain English
65
Dependency injection and named logins
20
WCF wiring / tracing and activity identification using log4net or NLog
nine
Nlog - Create a header for a log file
five
How to log System.Diagnostics.Trace and System.Diagnostics.Debug messages to NLog file?
1
Disable debug messages from a specific assembly
1
Login to different files with NLog and configure it with NLog Config XML
0
NLog Mail error when used in web application
0
Log name in nLog is truncated
0
How to track a specific endpoint on a System.Net source



All Articles
Loading...
X
Show
Funny
Dev
Pics