diff --git a/tsNotificacionesClient.vb b/tsNotificacionesClient.vb
index b5c62ff..bf0eea7 100644
--- a/tsNotificacionesClient.vb
+++ b/tsNotificacionesClient.vb
@@ -1,12 +1,13 @@
Imports System.Configuration
+Imports System.Diagnostics
Imports System.IO
Imports System.Net
Imports System.Net.Http
Imports System.Net.Http.Headers
Imports System.Net.Http.Json
+Imports System.Runtime.InteropServices
Imports Microsoft.Extensions.Configuration
Imports Microsoft.Extensions.Logging
-Imports System.Diagnostics
Public Class TsNotificacionesClient
@@ -15,16 +16,20 @@ Public Class TsNotificacionesClient
' ============================================================
Private NotInheritable Class LogProvider
Private Shared ReadOnly _factory As ILoggerFactory = LoggerFactory.Create(
- Sub(builder)
- builder.AddConsole() ' Linux → journald
- builder.AddEventLog() ' Windows → Event Viewer
- End Sub)
+ Sub(builder)
+ builder.AddConsole() ' Linux → OK
+
+ If OperatingSystem.IsWindows() Then
+ builder.AddEventLog() ' Solo Windows
+ End If
+ End Sub)
Public Shared Function CreateLogger(Of T)() As ILogger(Of T)
Return _factory.CreateLogger(Of T)()
End Function
End Class
+
' ============================================================
' CAMPOS DE INSTANCIA
' ============================================================
@@ -61,40 +66,32 @@ Public Class TsNotificacionesClient
Dim apiKey = If(config("TsNotificaciones:ApiKey"), String.Empty)
Dim nombreServidor = If(config("TsNotificaciones:NombreServidor"), Environment.MachineName)
- Dim EsWindows = OperatingSystem.IsWindows()
- If IncluirMensajeEnLogDelSistema Then
+ If IncluirMensajeEnLogDelSistema AndAlso RuntimeInformation.IsOSPlatform(OSPlatform.Windows) Then
- ' ============================================================
- ' LOGGING MULTIPLATAFORMA
- ' ============================================================
- If EsWindows Then
- ' --- WINDOWS: Event Viewer ---
+ ' --- WINDOWS: Event Viewer ---
+ Dim ele As EventLogEntryType
+ Select Case Tipo
+ Case TipoNotificacionEnum.INFO
+ ele = EventLogEntryType.Information
+ Case TipoNotificacionEnum.ADVERTENCIA
+ ele = EventLogEntryType.Warning
+ Case TipoNotificacionEnum.ERROR, TipoNotificacionEnum.CRÍTICO
+ ele = EventLogEntryType.Error
+ End Select
+ EventLog.WriteEntry(".NET Runtime", $"{Aplicacion} {titulo} {descripcion}", ele, 1000)
- Dim ele As EventLogEntryType
- Select Case Tipo
- Case TipoNotificacionEnum.INFO
- ele = EventLogEntryType.Information
- Case TipoNotificacionEnum.ADVERTENCIA
- ele = EventLogEntryType.Warning
- Case TipoNotificacionEnum.ERROR, TipoNotificacionEnum.CRÍTICO
- ele = EventLogEntryType.Error
- End Select
-
- EventLog.WriteEntry(".NET Runtime", $"{Aplicacion} {titulo} {descripcion}", ele, 1000)
-
- Else
- ' --- LINUX: ILogger → journald ---
- Select Case Tipo
- Case TipoNotificacionEnum.INFO
- logger.LogInformation($"{titulo} {descripcion}")
- Case TipoNotificacionEnum.ADVERTENCIA
- logger.LogWarning($"{titulo} {descripcion}")
- Case TipoNotificacionEnum.ERROR, TipoNotificacionEnum.CRÍTICO
- logger.LogError($"{titulo} {descripcion}")
- End Select
- End If
+ ElseIf IncluirMensajeEnLogDelSistema Then
+ ' --- LINUX: ILogger → journald ---
+ Select Case Tipo
+ Case TipoNotificacionEnum.INFO
+ logger.LogInformation($"{titulo} {descripcion}")
+ Case TipoNotificacionEnum.ADVERTENCIA
+ logger.LogWarning($"{titulo} {descripcion}")
+ Case TipoNotificacionEnum.ERROR, TipoNotificacionEnum.CRÍTICO
+ logger.LogError($"{titulo} {descripcion}")
+ End Select
End If
' ============================================================
diff --git a/tsUtilidades.vbproj b/tsUtilidades.vbproj
index aef7562..9ddfcfd 100644
--- a/tsUtilidades.vbproj
+++ b/tsUtilidades.vbproj
@@ -16,11 +16,12 @@
net8.0
tsUtilidades
net8.0, libreria
- 1.1.15
+ 1.1.16
Manuel
Tecnosis S.A
Utilidades Varias
+ - 2026-05-19 1.1.16 Corrección multiplataforma tsNotificacionesClient
- 2026-05-12 1.1.15 Se corrige tsNotificacionesClient
- 2026-04-10 1.1.14 Se corrige tsNotificacionesClient
- 2026-04-10 1.1.13 Se corrige tsNotificacionesClient