Write contextual diagnostic log entry¶
This operation centralizes diagnostic logging for the library. Every log call routes through it, ensuring each message reaches log4net carrying the current host address, request URL, application name, and a reduced call-stack trail — so authentication activity can be reconstructed from the logs even though the individual authenticator classes never format their own log entries.
| Field | Value |
|---|---|
| Operation ID | write-contextual-diagnostic-log-entry |
| Trigger | Library code calls LogInfo, LogWarn, LogError, or LogDebug. |
| Inputs | Message text, current HttpContext, current stack trace |
| Outputs | Formatted log4net entry |
| Primary components | mdlLogging.LogInfo, mdlLogging.LogWarn, mdlLogging.LogError, mdlLogging.LogDebug, mdlLogging.LogMsg |
| Entry point | SAIF.Framework.SecurityModule\mdlLogging.vb |
Steps¶
- On first use, lazily initialize
m_logby callingLogManager.GetLogger(GetType(clsSecurityModule).Name), so the logger is created once per application lifetime rather than on every call. - Route the severity-specific helper the caller invoked (
LogInfo,LogWarn,LogError, orLogDebug) throughLogMsg, passing the matching log4net formatter delegate. - Inside
LogMsg, read the application path, host address, and request URL fromHttpContext.Current.Request. - Build a call-stack summary by scanning
StackTrace.GetFrames(): keep only frames declared onclsSecurityModule, skip helper-frame names beginning withASSERTorGETSTACKFRAMES, reverse the remaining sequence so it reads outer-to-inner, and join the method names with->. - Format the final message as
{hostAddress},{requestUrl},{applicationName}->{stackFrames},{message}and invoke the requested log4net delegate with that string.
Process flow¶
The following diagram visualizes this operation's control flow.
flowchart TD
Start([Logging helper called]) --> S1[Get or create logger]
S1 --> S2[Collect request context]
S2 --> S3[Derive stack-frame trail]
S3 --> S4[Format combined message]
S4 --> EndOk([Write log4net entry])
Failure and edge-case behavior¶
- The operation assumes
HttpContext.CurrentandHttpContext.Current.Requestare available whenever logging is invoked; it does not guard against a null ambient context. - The reduced stack trace includes only frames declared on
clsSecurityModule, so it does not show intermediate frames when a log call originates from other helper classes in the call chain.
Related documentation¶
Sources¶
SAIF.Framework.SecurityModule\mdlLogging.vb