Hi
we need to implement central logging for a Powershell Connector, sending logs to a fluentd endpoint.
So I got the dll and placed it next to the Nlog.dll in C:\Program Files\One Identity\One Identity Manager
and updated the globallog.config:
--
<extensions>
<add assembly="NLog.Targets.Fluentd" />
</extensions>
#dummy layout
<variable name="Audit" xsi:type="JsonLayout" value="${longdate} ${level:upperCase=true} (${logger}"/>
<targets>
<target xsi:type="Fluentd" name="Audit"
host="fluent-aggregator"
tag="audit.oneidentity"
noDelay="true"
sendBufferSize="8192"
sendTimeout="2"
lingerEnabled="false"
lingerTime="2"
emitStackTraceWhenAvailable="false"
layout="${Audit}"
/>
...
<rules>
<logger name="Audit" writeTo="Audit"/>
...
--
Thats how Im calling the logger
--
$null = [System.Reflection.Assembly]::LoadFile("C:\Program Files\One Identity\One Identity Manager\NLog.dll")
function Get-DSNLogger1IM() {
param (
[String] $Logger
)
$xmlConfig = New-Object NLog.Config.XmlLoggingConfiguration("C:\Program Files\One Identity\One Identity Manager\globallog.config")
[NLog.LogManager]::Configuration = $xmlConfig
$Log = [NLog.LogManager]::GetLogger("$($Logger)")
return($Log)
}
$LogAudit = Get-DSNLogger1IM -Logger Audit
$LogAudit.Info("test")
--
However running the above creates an error in nlog's internal log file:
--
2024-06-21 10:29:38.5614 Info Loading assembly: NLog.Targets.Fluentd
2024-06-21 10:29:38.5614 Trace Try find 'NLog.Targets.Fluentd' in current domain
2024-06-21 10:29:38.5614 Trace Haven't found' 'NLog.Targets.Fluentd' in current domain
2024-06-21 10:29:38.5771 Warn Error has been raised. Exception: NLog.NLogConfigurationException: Error loading extensions: NLog.Targets.Fluentd ---> System.IO.FileNotFoundException: Could not load file or assembly 'NLog.Targets.Fluentd' or one of its dependencies. The system cannot find the file specified.
at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection)
at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
at System.Reflection.Assembly.Load(String assemblyString)
at NLog.Internal.AssemblyHelpers.LoadFromName(String assemblyName)
at NLog.Config.LoggingConfigurationParser.ParseExtensionWithAssembly(String assemblyName, String prefix)
--- End of inner exception stack trace ---
--
Any ideas?
Alternatively we could use syslog but Nlog's syslog integration throws similar errors.
Thanks
Jonas
OIM 9.1.1