Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Using NLog a required dependency isn't provded by NuGet #79

Closed
johnjaylward opened this issue May 19, 2020 · 0 comments
Closed

[BUG] Using NLog a required dependency isn't provded by NuGet #79

johnjaylward opened this issue May 19, 2020 · 0 comments
Labels
bug Something isn't working

Comments

@johnjaylward
Copy link

johnjaylward commented May 19, 2020

ECS schema version (e.g. 1.4.0):
1.5.0

ECS .NET assembly version (e.g. 1.4.2):
1.5.0

Elasticsearch version (if applicable):
7.2+

.NET framework / OS:
windows dotnetcore 3.1

Description of the problem, including expected versus actual behavior:
When NLog starts up using a default configured EcsLayout, an exception is thrown that ElasticApmTraceId can not be found. This is because ElasticApmTraceId and ElasticApmTransactionId are defined in Package Elastic.Apm.NLog, however Elastic.Apm.NLog is not a required dependency of Elastic.CommonSchema.NLog through NuGet

Steps to reproduce:

  1. Add NLog.Targets.ElasticSearch (alpha version, see above) and Elastic.CommonSchema.NLog 1.5.0 to your project.
  2. Configure the project using the minimal options:
<extensions>
    <add assembly="NLog.Targets.ElasticSearch"/>
    <add assembly="Elastic.CommonSchema.NLog"/>
</extensions>
<targets>
   <target xsi:type="ElasticSearch" enableJsonLayout="true">
       <layout xsi:type="EcsLayout" />
   </target>
</targets>
  1. Try to write a log message that is routed to the elastic target

exception is thrown:

System.TypeInitializationException
  HResult=0x80131534
  Message=The type initializer for 'Program' threw an exception.
  Source=Program
  StackTrace:
   at Program.<Main>d__7.MoveNext() in ....\Program.cs:line 34

  This exception was originally thrown at this call stack:
    [External Code]

Inner Exception 1:
NLogConfigurationException: Exception when parsing ....\bin\Debug\netcoreapp3.1\NLog.config. 

Inner Exception 2:
TargetInvocationException: Exception has been thrown by the target of an invocation.

Inner Exception 3:
ArgumentException: LayoutRenderer cannot be found: 'ElasticApmTraceId'

Expected Behavior:
Either the NuGet package should list Elastic.Apm.NLog as a dependency, or the Layout should be configured that it only uses items out of the Elastic.Apm.NLog package when it's available (possibly through reflection or a configuration option)

@johnjaylward johnjaylward added the bug Something isn't working label May 19, 2020
Mpdreamz added a commit that referenced this issue Jun 2, 2020
v1v added a commit to v1v/ecs-dotnet that referenced this issue Jun 8, 2020
…utomation

* upstream/master: (28 commits)
  bump version to 1.5.1
  move to released assembly differ
  Expose Serialize(StringBuilder) overload (elastic#82)
  fix elastic#79 only inject layout renderer keys for APM if Elastic.Apm.NLog … (elastic#83)
  upgrade Bullseye from 3.0.0 to 3.3.0 (elastic#70)
  NLog EcsLayout - Added support for Log Origin (elastic#78)
  add benchmarks for simple serialization cases (elastic#81)
  update integration tests
  move to Elastic.Elasticsearch.Xunit
  NLog Ecs Layout event Enrichment (elastic#74)
  Microsoft.AspNetCore.Http.Abstractions ver. 2.1.0 has LTS (elastic#76)
  EcsLayout - Use LogEventInfo.Logger instead of hardcoded DefaultLogger (elastic#67)
  Added Beta Notice (elastic#65)
  Bump to 1.5.0
  Implement ECS schema 1.5 (elastic#60)
  Update branch name
  Bump to 1.4.4
  Increase Elastic.Apm dependency to 1.4.0 (elastic#66)
  Bump to 1.4.3
  Modify accessors to mark internal/private and to not expose outside of assembly.
  ...
russcam pushed a commit that referenced this issue Jun 1, 2021
#83)

* fix #79 only inject layout renderer keys for APM if Elastic.Apm.NLog is referenced

* move logic to class instantation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant