VOOZH about

URL: https://deepwiki.com/Accenture/Ocaramba/2.7-logging:-testlogger-nlog-and-eventfiringwebdriver

⇱ Logging: TestLogger, NLog, and EventFiringWebDriver | Accenture/Ocaramba | DeepWiki


Loading...
Last indexed: 6 June 2026 (fb3580)
Menu

Logging: TestLogger, NLog, and EventFiringWebDriver

The Ocaramba logging subsystem provides a multi-layered approach to capturing test execution data. It combines high-level test lifecycle logging via TestLogger, detailed Selenium event interception via MyEventFiringWebDriver, and a robust backend powered by NLog. This system ensures that every interaction, from test start to browser navigation and element clicks, is recorded in both the console and persistent log files.

Logging Architecture and Data Flow

The logging system is integrated directly into the framework's operational flow. When a driver is initialized, Ocaramba wraps the standard IWebDriver in an EventFiringWebDriver (specifically the MyEventFiringWebDriver implementation) to hook into Selenium events OcarambaLite/Logger/MyEventFiringWebDriver.cs33-34 High-level test events are managed by TestLogger, which uses NLog.LogManager to obtain a logger instance OcarambaLite/Logger/TestLogger.cs39

Logging Component Relationship

This diagram illustrates how the logging entities interact within the Ocaramba framework.

Logging Entity Map


Sources: OcarambaLite/Logger/MyEventFiringWebDriver.cs33-36 OcarambaLite/Logger/TestLogger.cs39 OcarambaLite/nlog.config11-15 OcarambaLite/Verify.cs37

TestLogger

The TestLogger class acts as a wrapper around NLog to provide standardized logging for test boundaries OcarambaLite/Logger/TestLogger.cs34-39

Key Methods

Sources: OcarambaLite/Logger/TestLogger.cs34-128

MyEventFiringWebDriver

The MyEventFiringWebDriver class extends Selenium's EventFiringWebDriver OcarambaLite/Logger/MyEventFiringWebDriver.cs33-34 It overrides specific event hooks to automatically log internal WebDriver actions at the Trace level OcarambaLite/Logger/MyEventFiringWebDriver.cs52

Event Hooks and Logic

The class intercepts various lifecycle events to provide an audit log of browser interactions:

Event HookLogged Information
OnNavigatingThe target URL OcarambaLite/Logger/MyEventFiringWebDriver.cs50-54
OnElementClickingDetailed representation of the element being clicked OcarambaLite/Logger/MyEventFiringWebDriver.cs60-64
OnFindingElementThe FindMethod (By locator) used OcarambaLite/Logger/MyEventFiringWebDriver.cs90-94
OnScriptExecutingThe JavaScript code string OcarambaLite/Logger/MyEventFiringWebDriver.cs100-104
OnScriptExecutedConfirmation of script execution OcarambaLite/Logger/MyEventFiringWebDriver.cs110-114
OnElementValueChangingThe element state before value modification OcarambaLite/Logger/MyEventFiringWebDriver.cs70-74
OnElementValueChangedThe element state after value modification OcarambaLite/Logger/MyEventFiringWebDriver.cs80-84

Element String Representation

The helper method ToStringElement constructs a detailed string of an IWebElement by extracting its attributes: id, name, value, class, type, role, text, and href OcarambaLite/Logger/MyEventFiringWebDriver.cs121-135 The AppendAttribute method handles the logic for fetching these attributes or the element text using e.Element.Text or e.Element.GetAttribute(attribute) OcarambaLite/Logger/MyEventFiringWebDriver.cs143-147

Sources: OcarambaLite/Logger/MyEventFiringWebDriver.cs33-148

NLog Configuration

Logging behavior is controlled via nlog.config files. These files define targets (where to write) and rules (what to write) OcarambaLite/nlog.config9-23

Target and Rules Configuration

The configuration typically defines two main targets:

  1. File Target (allfile): Writes logs to a file located in ${basedir}/TestOutput/. It uses concurrentWrites="true" and keepFileOpen="true" for performance OcarambaLite/nlog.config11-12
  2. Console Target (consolelog): Outputs logs to the standard console for real-time monitoring OcarambaLite/nlog.config13-14

Logging Level Hierarchy and Routing


Sources: Ocaramba.Tests.NUnit/nlog.config18-22 Ocaramba.Tests.MsTest/nlog.config18-22 Ocaramba.Tests.Xunit/nlog.config18-22

Soft Assertion Logging (Verify)

The Verify class also interacts with the logging subsystem. When a soft assertion fails within Verify.That, the exception is caught and logged as an Error level message OcarambaLite/Verify.cs109 This ensures that even if a test continues after a failure, the error is recorded in the NLog targets.

Sources: OcarambaLite/Verify.cs89-111

Log Output Directories

Logs are written to the TestOutput folder relative to the execution directory. Each project specifies its own log file name:

ProjectLog File NameSource
Ocaramba.Tests.NUnitTestNUnit.logOcaramba.Tests.NUnit/nlog.config11
Ocaramba.Tests.MsTestTestMsTest.logOcaramba.Tests.MsTest/nlog.config11
Ocaramba.Tests.XunitTestXunit.logOcaramba.Tests.Xunit/nlog.config11
Ocaramba.Tests.FeaturesTestFeatures.logOcaramba.Tests.Features/nlog.config12
Ocaramba.Tests.AngularTestAngular.logOcaramba.Tests.Angular/nlog.config12
Ocaramba.UnitTestsTestUnit.logOcaramba.UnitTests/nlog.config12
CloudProviderTestCloud.logOcaramba.Tests.CloudProviderCrossBrowser/nlog.config12
NUnitExtentReportsTestNUnit.logOcaramba.Tests.NUnitExtentReports/nlog.config12

Sources: Ocaramba.Tests.NUnit/nlog.config11-15 Ocaramba.Tests.MsTest/nlog.config11-15 Ocaramba.Tests.Xunit/nlog.config11-15 Ocaramba.Tests.Angular/nlog.config12-15 Ocaramba.Tests.CloudProviderCrossBrowser/nlog.config12-15 Ocaramba.UnitTests/nlog.config12-15 Ocaramba.Tests.NUnitExtentReports/nlog.config12-15