ComponentSpace

Forums



Enabling SAML Trace


Enabling 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
SAML debug trace may be enabled to assist with tracking down issues.
The standard ASP.NET Core logging API is used.
In our examples, we make use of Serilog. However, any logging provider may be used to capture the logging information.
Regardless of the logging provider used, the "Debug" level must be specified for "ComponentSpace".
However, it's not recommended to enable SAML debug trace in production environments, unless for problem determination, as it may impact performance.
The following is an example Serilog configuration in appsettings.json. Logs are written to a "logs" folder under the application's root folder.


"Serilog": {
  "MinimumLevel": {
    "Default": "Warning",
    "Override": {
      "ComponentSpace": "Debug"
    }
  },
  "WriteTo": [
    {
      "Name": "Debug"
    },
    {
      "Name": "Async",
      "Args": {
         "configure": [
           {
             "Name": "File",
             "Args": {
               "path": "logs/saml-.log",
               "rollingInterval": "Day",
               "retainedFileCountLimit": 7,
               "buffered": true,
               "flushToDiskInterval": "00:00:01"
             }
           }
         ]
       }
     }
   ]
}



To support Serilog and the above configuration, the following NuGet packages must be included in the application.


Serilog.AspNetCore
Serilog.Sinks.Async
Serilog.Sinks.File



The following example CreateWebHostBuilder method in the Program class removes the default logging providers and adds the Serilog provider.


public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
  WebHost.CreateDefaultBuilder(args)
   .ConfigureLogging(configureLogging => configureLogging.ClearProviders())
   .UseSerilog((webHostBuilderContext, loggerConfiguration) =>
      loggerConfiguration.ReadFrom.Configuration(webHostBuilderContext.Configuration))
   .UseStartup<Startup>();




Regards
ComponentSpace Development
raju
raju
New Member
New Member (16 reputation)New Member (16 reputation)New Member (16 reputation)New Member (16 reputation)New Member (16 reputation)New Member (16 reputation)New Member (16 reputation)New Member (16 reputation)New Member (16 reputation)

Group: Awaiting Activation
Posts: 10, Visits: 41
ComponentSpace - 5/26/2017
The SAML library may be configured to enable SAML trace to be written to a log file. This information can assist with tracking down issues.
The standard ASP.NET Core logging API is used.
An example logging configuration from appsettings.json follows.


"Logging": {
  "IncludeScopes": false,
  "LogLevel": {
    "Default": "Warning"
  }
}


The BuildWebHost method from the Program class adds the configured logging.
In this example Serilog is used but any logging mechanism may be specified.


public static IWebHost BuildWebHost(string[] args) =>
  WebHost.CreateDefaultBuilder(args)
   .ConfigureLogging((hostingContext, logging) =>
   {
    logging.AddConfiguration(hostingContext.Configuration.GetSection("Logging"));
    logging.AddConsole();
    logging.AddDebug();
    logging.AddSerilog(new LoggerConfiguration()
      .MinimumLevel.Debug()
      .WriteTo.RollingFile("Logs/saml-{Date}.log")
      .Filter.ByIncludingOnly(Matching.FromSource("ComponentSpace.Saml2"))
      .CreateLogger());
   })
   .UseStartup<Startup>()
   .Build();



Thank you.
But I added the below to Configure method in Startup.cs, I don't see the log file in that expected directory. I ran SAML SSO to reproduce the problem.
Can you please help with this and also tell possible reasons why 500 Internal Server Error could be sent while in the process of generating SAML Response

loggerFactory.AddSerilog(new LoggerConfiguration()
     .MinimumLevel.Debug()
     .WriteTo.RollingFile("Logs/saml-{Date}.log")
     .Filter.ByIncludingOnly(Matching.FromSource("ComponentSpace.Saml2"))
     .CreateLogger());



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 500 internal error usually means an exception was thrown.
If you run in the Visual Studio debugger it should show the exception and stack trace.
A common cause is configuration mismatches but it's hard to be certain without the details of the exception. 
Do you see any logging in the console window?
The above Serilog configuration is what we use in our example projects and should generate log files if setup correctly.

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