question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

LoggerImpl Handler: Error creating native log file.

See original GitHub issue

Describe the bug When starting up my .NET 5 project, I receive the following error.

LoggerImpl Handler: Error creating native log file.

To Reproduce Steps to reproduce the behavior:

  1. Created a brand new .NET 5 Console Application
  2. Added dockerfile with the following datadog information per the documentation.
RUN curl -LO https://github.com/DataDog/dd-trace-dotnet/releases/download/v1.28.2/datadog-dotnet-apm_1.28.2_amd64.deb
RUN dpkg -i ./datadog-dotnet-apm_1.28.2_amd64.deb

ENV CORECLR_ENABLE_PROFILING=1
ENV CORECLR_PROFILER={846F5F1C-F9AE-4B07-969E-05C26BC060D8}
ENV CORECLR_PROFILER_PATH=/opt/datadog/Datadog.Trace.ClrProfiler.Native.so
ENV DD_INTEGRATIONS=/opt/datadog/integrations.json
ENV DD_DOTNET_TRACER_HOME=/opt/datadog

Expected behavior I expected it to start up without a problem.

Runtime environment (please complete the following information):

  • Instrumentation mode: Automatic
  • Tracer version: 1.28.2
  • OS: Linux
  • CLR: .NET 5

Additional context I’m running this is a linux docker container using the .NET 5 runtime.

FROM mcr.microsoft.com/dotnet/runtime:5.0 AS base

Workaround If I add the trace log path environment variable and set it to the default datadog trace location, it works fine.

Here’s a link to a github project with the example. https://github.com/jrmccannon/datadog-1.28.2-test

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
andrewlockcommented, Aug 10, 2021

Hi @jrmccannon, thanks for reaching out.

I think you’re missing a line in your Dockerfile that runs the script (included in the deb file) that creates the log path and updates permissions (as described in the docs). For example, you should have something like:

RUN curl -LO https://github.com/DataDog/dd-trace-dotnet/releases/download/v1.28.2/datadog-dotnet-apm_1.28.2_amd64.deb
RUN dpkg -i ./datadog-dotnet-apm_1.28.2_amd64.deb

# Add this line 
RUN chmod +x /opt/datadog/createLogPath.sh && /opt/datadog/createLogPath.sh

# ... other variables as before

This creates the default log directory (/var/log/datadog/dotnet) and adds permissions to write to the directory, alternatively, you can set the log path to an existing directory using DD_TRACE_LOG_DIRECTORY as you mentioned.

The behaviour changed in this PR to print to stderr when we can’t write logs. We will revert that behaviour so that we don’t print to stderr on startup, but you will still want to create the log directory nevertheless 🙂

0reactions
andrewlockcommented, Aug 11, 2021

Hi @lucianoeger, yes, the solution will be the same - either create the default log path at /var/log/datadog/dotnet and ensure it is writeable (the easiest way is by running the createLogPath.sh included in the linux packages) or set a different (existing) directory using the DD_TRACE_LOG_DIRECTORY environment variable. We have merged a fix for the issue, which should be included in the next release, but we advise you take the above steps regardless 🙂

Read more comments on GitHub >

github_iconTop Results From Across the Web

Serilog does not create log files
and the Handle method, which is located in the MaterialCommandHandler class, in which I want to write something into the log file
Read more >
Error creating native log file message logged when no ...
When setting up DataDog with Serilog in .Net an error is thrown an every deployment when no File sinks are registered with Serilog....
Read more >
Sink is not creating Logger file on .Net Core · Issue #75
When i tried to create logger using following code: var log = new LoggerConfiguration() .WriteTo.
Read more >
Logging configuration
Quarkus includes several different log handlers: console, file, and syslog. The featured examples use com.example as a logging category. Console log handler.
Read more >
Serilog Tutorial for .NET Logging: 16 Best Practices and Tips
Serilog makes it easy to record custom object properties and output your logs to JSON. Read this Serilog tutorial for best practices and ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found