@@ -21,6 +21,7 @@ As a real example of using this framework, see [TabShell](https://github.com/tec
2121 * [ Component Lifecycle] ( #component-lifecycle )
2222 * [ Component Tree] ( #component-tree )
2323 * [ Imperative Component Management] ( #component-imperative )
24+ * [ Component Logging] ( #component-logging )
2425 * [ Component Code Example] ( #component-code )
2526 * [ When to Create a Component?] ( #when-to-create-component )
2627 * [ When not to Create a Component?] ( #when-not-to-create-component )
@@ -322,6 +323,24 @@ tabs, dialogs, or search panels).
322323This approach ensures that PatternFX components behave predictably, remain testable, and can support complex,
323324long-living, dynamic UI applications.
324325
326+ ### Component Logging <a name =" component-logging " ></a >
327+
328+ PatternFX supports component-scoped logging, allowing log messages to be produced in the context of a specific
329+ component instance rather than only at the class or subsystem level. This approach is especially useful in complex and
330+ dynamic applications where multiple instances of the same component type may exist simultaneously (for example, tabs,
331+ dialogs, editors, or background components). Component-scoped logging makes it possible to precisely identify the
332+ exact source of a log message and greatly simplifies debugging and diagnostics.
333+
334+ Each component exposes a log prefix that uniquely identifies its instance. This prefix can be obtained via the
335+ ` Component#getLogPrefix() ` method and is also available to the ` ViewModel ` through ` ComponentMediator#getLogPrefix() ` .
336+
337+ In the default implementation (` AbstractComponent ` ), the log prefix is determined during construction by calling the
338+ protected method ` resolveLogPrefix() ` . By default, this method delegates to a static
339+ ` Function<AbstractComponent<?>, String> logPrefixResolver ` (which can be customized), which defines a consistent
340+ application-wide policy for computing log prefixes. This design allows all components to share a uniform logging format
341+ by default, while still enabling subclasses to override ` resolveLogPrefix() ` and provide a custom log prefix when needed.
342+ The resolved log prefix is stored in the component instance and remains stable for the component's entire lifecycle.
343+
325344### Component Code Example<a name =" component-code " ></a >
326345
327346This example demonstrates the creation of a Foo component that dynamically adds a child Bar component.
0 commit comments