ComponentSpace

Forums



Enabing SAML Trace


Enabing SAML Trace

Author
Message
ComponentSpace
ComponentSpace
ComponentSpace Development
ComponentSpace Development (2.9K reputation)ComponentSpace Development (2.9K reputation)ComponentSpace Development (2.9K reputation)ComponentSpace Development (2.9K reputation)ComponentSpace Development (2.9K reputation)ComponentSpace Development (2.9K reputation)ComponentSpace Development (2.9K reputation)ComponentSpace Development (2.9K reputation)ComponentSpace Development (2.9K reputation)

Group: Administrators
Posts: 2K, Visits: 4.6K

The SAML component may be configured to enable SAML trace to be written to a log file. This information can assist with tracking down issues.
It is not recommended that SAML trace is left enabled in production systems as this may have an impact on performance.

Configure SAML Trace
Update your application’s web.config to include a <system.diagnostics> section as shown in the configuration below.
Log files are written to the logs sub-folder under your application's root folder.


<system.diagnostics>
    <trace autoflush="true">
      <listeners>
         <add name="CyclicTextWriter"/>
      </listeners>
    </trace>
    <sources>
      <source name="ComponentSpace.SAML2" switchValue="Verbose">
        <listeners>
          <add name="CyclicTextWriter"/>
        </listeners>
      </source>
    </sources>
    <sharedListeners>
      <!-- Ensure IIS has create/write file permissions for the log folder. -->
      <add
        name="CyclicTextWriter"
        type="ComponentSpace.SAML2.Utility.CyclicTraceListener,ComponentSpace.SAML2"
        initializeData="logs"/>
    </sharedListeners>
</system.diagnostics>





Regards
ComponentSpace Development
rob.ehle@benaissance.com
rob.ehle@benaissance.com
New Member
New Member (1 reputation)New Member (1 reputation)New Member (1 reputation)New Member (1 reputation)New Member (1 reputation)New Member (1 reputation)New Member (1 reputation)New Member (1 reputation)New Member (1 reputation)

Group: Forum Members
Posts: 1, Visits: 2
Is there a simple way to toggle the diagnostics? (Without touching the config file)
ComponentSpace
ComponentSpace
ComponentSpace Development
ComponentSpace Development (2.9K reputation)ComponentSpace Development (2.9K reputation)ComponentSpace Development (2.9K reputation)ComponentSpace Development (2.9K reputation)ComponentSpace Development (2.9K reputation)ComponentSpace Development (2.9K reputation)ComponentSpace Development (2.9K reputation)ComponentSpace Development (2.9K reputation)ComponentSpace Development (2.9K reputation)

Group: Administrators
Posts: 2K, Visits: 4.6K
Hi Rob
We use the standard ASP.NET system diagnostics for logging. I'm not aware of any way to toggle logging on or off other than by updating the web.config.


Regards
ComponentSpace Development
scottclem
scottclem
New Member
New Member (1 reputation)New Member (1 reputation)New Member (1 reputation)New Member (1 reputation)New Member (1 reputation)New Member (1 reputation)New Member (1 reputation)New Member (1 reputation)New Member (1 reputation)

Group: Forum Members
Posts: 1, Visits: 1

What are the other values for switchValue?   I'd like to turn off the logging, but not have to remove all of the config settings.


ComponentSpace
ComponentSpace
ComponentSpace Development
ComponentSpace Development (2.9K reputation)ComponentSpace Development (2.9K reputation)ComponentSpace Development (2.9K reputation)ComponentSpace Development (2.9K reputation)ComponentSpace Development (2.9K reputation)ComponentSpace Development (2.9K reputation)ComponentSpace Development (2.9K reputation)ComponentSpace Development (2.9K reputation)ComponentSpace Development (2.9K reputation)

Group: Administrators
Posts: 2K, Visits: 4.6K
Replace    
    <source name="ComponentSpace.SAML2" switchValue="Verbose">
with
    <source name="ComponentSpace.SAML2" switchValue="Off">

Alternatively, comment out the <system.diagnostics> section.


Regards
ComponentSpace Development
jinimg
jinimg
New Member
New Member (3 reputation)New Member (3 reputation)New Member (3 reputation)New Member (3 reputation)New Member (3 reputation)New Member (3 reputation)New Member (3 reputation)New Member (3 reputation)New Member (3 reputation)

Group: Forum Members
Posts: 3, Visits: 10
Hi team,

I would like to use the log4net library for logging. Because I am not using the System.Diagnostics.Trace in the application anymore. I tried different options but I could not find a method to forward SAML Trace to log4net. Please help me

Thanks,
MG
ComponentSpace
ComponentSpace
ComponentSpace Development
ComponentSpace Development (2.9K reputation)ComponentSpace Development (2.9K reputation)ComponentSpace Development (2.9K reputation)ComponentSpace Development (2.9K reputation)ComponentSpace Development (2.9K reputation)ComponentSpace Development (2.9K reputation)ComponentSpace Development (2.9K reputation)ComponentSpace Development (2.9K reputation)ComponentSpace Development (2.9K reputation)

Group: Administrators
Posts: 2K, Visits: 4.6K
We use the standard .NET System.Diagnostics.TraceListener. We don't natively support log4net.
You could either implement your own TraceListener that writes to log4net or search for an existing implementation of this.

Regards
ComponentSpace Development
jinimg
jinimg
New Member
New Member (3 reputation)New Member (3 reputation)New Member (3 reputation)New Member (3 reputation)New Member (3 reputation)New Member (3 reputation)New Member (3 reputation)New Member (3 reputation)New Member (3 reputation)

Group: Forum Members
Posts: 3, Visits: 10
ComponentSpace - 3/15/2017
We use the standard .NET System.Diagnostics.TraceListener. We don't natively support log4net.
You could either implement your own TraceListener that writes to log4net or search for an existing implementation of this.

I wrote my own TraceListener and it caught all event logs other than Component Space. Is there any mandatory configuration for ComponentSpace.SAML ??

Please help.

MG
jinimg
jinimg
New Member
New Member (3 reputation)New Member (3 reputation)New Member (3 reputation)New Member (3 reputation)New Member (3 reputation)New Member (3 reputation)New Member (3 reputation)New Member (3 reputation)New Member (3 reputation)

Group: Forum Members
Posts: 3, Visits: 10
I am able to configure log4net instead of system trace. Posting the details here. may be helpful for others. 
---------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------
web.config
--------------
<system.diagnostics>  
  <sources>
   <source name="ComponentSpace.SAML2" switchValue="Verbose">
    <listeners>
    <add name="ComponentSpace" />
    </listeners>
   </source>
  </sources>
  <sharedListeners>
   <add name="ComponentSpace" type="MyApp.Helper.Log4netTraceListener, MyApp" /> <!--this is the class namespace and the referral assembly name-->
  </sharedListeners>
  </system.diagnostics>

<log4net>
  <root>
  <level value="ALL" />
  <appender-ref ref="RollingFileAppender" />
  </root>
  <appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
  <file value="Logs\rolling.log" />
  <appendToFile value="true" />
  <rollingStyle value="Size" />
  <maxSizeRollBackups value="2" />
  <maximumFileSize value="5KB" />
  <staticLogFileName value="true" />
  <layout type="log4net.Layout.PatternLayout">
   <conversionPattern value="%date{dd/MMM/yyyy HH:mm:ss tt} [%thread] - %message%newline" />
  </layout>
  </appender>
</log4net>

Custom listener class override 
----------------------------------------------
namespace MyApp.Helper
{
  public class Log4netTraceListener : TraceListener
  {
   private readonly ILog _logManager;

   public Log4netTraceListener()
    : this("System.Diagnostics.Redirection")
   {

   }

   public Log4netTraceListener(string name)
    : base(name)
   {
    _logManager = LogManager.GetLogger(name);
   }

   public override void Write(string message)
   {
    if (_logManager != null)
    {
      _logManager.Debug(message);
    }
   }

   public override void WriteLine(string message)
   {
    if (_logManager != null)
    {
      _logManager.Debug(message);
    }
   }

   public override void TraceEvent(TraceEventCache eventCache, string source, TraceEventType eventType, int id)
   {
    TraceEvent(eventCache, source, eventType, id, string.Empty, new object[0]);
   }

   public override void TraceEvent(TraceEventCache eventCache, string source, TraceEventType eventType, int id, string message)
   {
    TraceEvent(eventCache, source, eventType, id, message, new object[0]);
   }
 //And other overrides if needed......
 }
}

Global.asax
---------------
Add the listener in application start

protected void Application_Start()
 {    
    Trace.Listeners.Add(new Log4netTraceListener());
}

Thanks,
MG
ComponentSpace
ComponentSpace
ComponentSpace Development
ComponentSpace Development (2.9K reputation)ComponentSpace Development (2.9K reputation)ComponentSpace Development (2.9K reputation)ComponentSpace Development (2.9K reputation)ComponentSpace Development (2.9K reputation)ComponentSpace Development (2.9K reputation)ComponentSpace Development (2.9K reputation)ComponentSpace Development (2.9K reputation)ComponentSpace Development (2.9K reputation)

Group: Administrators
Posts: 2K, Visits: 4.6K
Thanks MG for sharing.

Regards
ComponentSpace Development
GO


Similar Topics


Execution: 0.000. 2 queries. Compression Enabled.
Login
Existing Account
Email Address:


Password:


Social Logins

Select a Forum....









ComponentSpace Forums


Search