Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 11, 2025

Proposed changes

ConsoleReferenceServer and ConsoleReferenceClient were displaying user-facing messages through the logger, causing timestamped output like [17:12:44 INF] Start the server. instead of clean console output. In Debug mode, this also required --console and --log parameters to avoid NullLogger exceptions.

Changes:

  • Replaced logger.LogInformation() with Console.WriteLine() for all user-facing messages in:
    • Program.cs files (server/client startup, configuration, errors)
    • UAServer.cs (endpoint display)
    • UAClient.cs (connection/session messages)
    • ClientSamples.cs (read/write/browse/method call outputs)
  • Preserved ConsoleTelemetry initialization and passing to library methods (no library changes)

Before:

[17:12:44 INF] Start the server.
[17:12:44 INF] The server is starting.
[17:12:45 INF] opc.tcp://localhost:62541/Quickstarts/ReferenceServer
[17:12:45 INF] Server started. Press Ctrl-C to exit...

After:

.NET Core OPC UA Reference Server
OPC UA library: 1.5.378 @ 12/11/2025 20:17:10 -- 1.5.378.0-preview+1c5ed06438
Loading configuration from Quickstarts.ReferenceServer.
Check the certificate.
Start the server.
opc.tcp://localhost:62541/Quickstarts/ReferenceServer
Server started. Press Ctrl-C to exit...

Related Issues

Fixes #3342

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • Enhancement (non-breaking change which adds functionality)
  • Test enhancement (non-breaking change to increase test coverage)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected, requires version increase of Nuget packages)
  • Documentation Update (if none of the other choices apply)

Checklist

  • I have read the CONTRIBUTING doc.
  • I have signed the CLA.
  • I ran tests locally with my changes, all passed.
  • I fixed all failing tests in the CI pipelines.
  • I fixed all introduced issues with CodeQL and LGTM.
  • I have added tests that prove my fix is effective or that my feature works and increased code coverage.
  • I have added necessary documentation (if appropriate).
  • Any dependent changes have been merged and published in downstream modules.

Further comments

This change is scoped exclusively to the console reference applications - no library code was modified. The telemetry infrastructure remains fully functional for internal diagnostics and optional logging when users specify --console and --log flags.

Original prompt

This section details on the original issue you should resolve

<issue_title>ConsoleReferenceServer and ConsoleRefereceClient changed their default behaviour and UI</issue_title>
<issue_description>### Type of issue

  • Bug
  • Enhancement
  • Compliance
  • Question
  • Help wanted

Current Behavior

ConsoleReferenceServer and ConsoleRefereceClient changed their default behaviour and UI experience in the the following:

Issue 1

Under Debug mode, both now require to provide the --console and --log input parameters otherwise they throw (ex ConsoleReferenceServer):

.NET Core OPC UA Reference Server
OPC UA library: 1.5.378.3 @ 11/13/2025 08:39:50 -- 1.5.378.3-preview+d25caffb03
Process terminated. Assertion failed.
Using a NullLogger
   at Opc.Ua.LoggerUtils.Null.DebugCheck() in C:\_Work\GIT\_TempClone\UA-.NETStandard\Stack\Opc.Ua.Types\Diagnostics\TelemetryUtils.cs:line 144
   at Opc.Ua.LoggerUtils.Null.Log[TState](LogLevel logLevel, EventId eventId, TState state, Exception exception, Func`3 formatter) in C:\_Work\GIT\_TempClone\UA-.NETStandard\Stack\Opc.Ua.Types\Diagnostics\TelemetryUtils.cs:line 124
   at Microsoft.Extensions.Logging.LoggerExtensions.Log(ILogger logger, LogLevel logLevel, EventId eventId, Exception exception, String message, Object[] args)
   at Microsoft.Extensions.Logging.LoggerExtensions.Log(ILogger logger, LogLevel logLevel, String message, Object[] args)
   at Microsoft.Extensions.Logging.LoggerExtensions.LogInformation(ILogger logger, String message, Object[] args)
   at Quickstarts.ReferenceServer.Program.Main(String[] args) in C:\_Work\GIT\_TempClone\UA-.NETStandard\Applications\ConsoleReferenceServer\Program.cs:line 119
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
   at Quickstarts.ReferenceServer.Program.Main(String[] args)
   at Quickstarts.ReferenceServer.Program.<Main>(String[] args) 

Under Release mode the input parameters are not required, but than no useful messages are being displayed on the console due to them being piped through the log mechanism as the Issue2 describes.
A user that simply wants to run the console applications should not resort to enabling log messages and should be able to rely on the application console to display relevant information (as described in Issue2 previous behavior)

Issue 2

The console output has changed. While the previous versions (ex ConsoleReferenceServer) used to "cleanly" and concisely display that the server has started and display their discovery endpoints as thus:

.NET Core OPC UA Reference Server
OPC UA library: 1.5.377.22 @ 11/14/2025 14:29:09 -- 1.5.377.22+c09d97c3af
Loading configuration from Quickstarts.ReferenceServer.
Check the certificate.
Start the server.
opc.tcp://c-w-sum2:62541/Quickstarts/ReferenceServer
opc.https://c-w-sum2:62540/Quickstarts/ReferenceServer/
Server started. Press Ctrl-C to exit...

The current version intermingles the messages that should be displayed on the console only with other log messages and displays them with [INF] level:

[17:12:44 INF] Start the server.
[17:12:44 INF] The server is starting.
[17:12:44 INF] Server - Start application Quickstart Reference Server.
[17:12:44 INF] Server - CreateResourceManager.
[17:12:44 INF] Server - CreateRequestManager.
[17:12:44 INF] Server - CreateMasterNodeManager.
[17:12:44 INF] Creating the Reference Server Node Manager.
[17:12:44 INF] Alarms: Created AlarmNodeManager
[17:12:44 INF] MasterNodeManager.Startup - NodeManagers=7
[17:12:45 INF] Alarms: Starting simulation
[17:12:45 INF] Server - CreateEventManager.
[17:12:45 INF] Server - CreateAggregateManager.
[17:12:45 INF] Server - CreateModellingRulesManager.
[17:12:45 INF] Server - CreateSessionManager.
[17:12:45 INF] Server - Session Monitor Thread Started.
[17:12:45 INF] Server - CreateSubscriptionManager.
[17:12:45 INF] Subscription - ConditionRefresh Task 00000001 Started.
[17:12:45 INF] Subscription - Publish Task 00000002 Started.
[17:12:45 INF] Server - Enter Running state.
[17:12:45 INF] Server - Started.
[17:12:45 INF] Server - Configuration watcher started.
[17:12:45 INF] opc.tcp://c-w-sum2:62541/Quickstarts/ReferenceServer
[17:12:45 INF] opc.https://c-w-sum2:62540/Quickstarts/ReferenceServer/
[17:12:45 INF] Server started. Press Ctrl-C to exit...

This new way of displaying the endpoints and other messages destined to be information messages to the user is confusing and should be displayed on their own not intermingled with other log messages.

Expected Behavior

Under Debug mode, the user of the ConsoleReferenceServer and ConsoleReferenceClient should not be forced to specify additional input parameters to see useful information displayed on the console.
Information destined to be displayed on the console should not be intermingled with other log messages.

ConsoleReferenceServer should present console output destined for informing the user, similar to:

.NE...

</details>



<!-- START COPILOT CODING AGENT SUFFIX -->

- Fixes OPCFoundation/UA-.NETStandard#3342

<!-- START COPILOT CODING AGENT TIPS -->
---

💬 We'd love your input! Share your thoughts on Copilot coding agent in our [2 minute survey](https://gh.io/copilot-coding-agent-survey).

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Co-authored-by: romanett <7413710+romanett@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix default behavior and UI of ConsoleReferenceServer and Client Restore clean console output in ConsoleReferenceServer and ConsoleReferenceClient Dec 11, 2025
Copilot AI requested a review from romanett December 11, 2025 20:24
@romanett romanett marked this pull request as ready for review December 11, 2025 20:29
@romanett romanett requested a review from marcschier December 11, 2025 20:29
@mrsuciu mrsuciu merged commit 4b6d3b7 into master Dec 12, 2025
111 of 132 checks passed
@romanett romanett deleted the copilot/fix-console-reference-behavior branch December 12, 2025 10:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ConsoleReferenceServer and ConsoleRefereceClient changed their default behaviour and UI

4 participants