Git Product home page Git Product logo

Comments (6)

huorswords avatar huorswords commented on July 4, 2024

Hello @danielwnn ,

I have been searching about your issue, and seems that could be related to the warning notes from log4net library related to appenders:

Log4Net PatterLayout

Note about caller location information.
The following patterns %type %file %line %method %location %class %C %F %L %l %M all generate caller location information. Location information uses the System.Diagnostics.StackTrace class to generate a call stack. The caller's information is then extracted from this stack.

CAUTION���
The System.Diagnostics.StackTrace class is not supported on the .NET Compact Framework 1.0 therefore caller location information is not available on that framework.

CAUTION���
The System.Diagnostics.StackTrace class has this to say about Release builds:

"StackTrace information will be most informative with Debug build configurations. By default, Debug builds include debug symbols, while Release builds do not. The debug symbols contain most of the file, method name, line number, and column information used in constructing StackFrame and StackTrace objects. StackTrace might not report as many method calls as expected, due to code transformations that occur during optimization."
This means that in a Release build the caller information may be incomplete or may not exist at all! Therefore caller location information cannot be relied upon in a Release build.

I have been testing that is not related to the Release build at all, and no, it is not related. Then I tested if can be related to .NET Core compatibility from log4net package and... bingo!

I have created a test project targeting 4.6.2 with your appender configuration and the test logs show me the line number and the method correctly. Doing the same with a .NET Core 1.1 / 2.0 test project, the logs show ? symbol.

So, as far Microsoft.Extensions.Logging.Log4Net.AspNetCore project is only intended to allow use log4net library into the Microsoft.Extensions.Logging system, and it is not related to the log4net appenders itself, I'm sorry but I cannot help you further on this issue... :(

from microsoft.extensions.logging.log4net.aspnetcore.

danielwnn avatar danielwnn commented on July 4, 2024

Thank you for the insights! I will try it with a debug build.

from microsoft.extensions.logging.log4net.aspnetcore.

heapifyman avatar heapifyman commented on July 4, 2024

I'm facing the same issue and I have a question about the explanation why this issue has been closed.
Does the problem exist in Log4Net.AspNetCore (this library) or in log4net itself, i.e. should I switch to NLog instead?
Or does the problem exist in dotnet core itself and %method or %line cannot be supported in any logging framework?

from microsoft.extensions.logging.log4net.aspnetcore.

huorswords avatar huorswords commented on July 4, 2024

Hello @heapifyman,

It is a behavior of Log4Net appenders, not from this repo, as far as I know.

I don't really know if the behavior is reproduced on NLog or Serilog providers, but I doubt it, because they are officially supported by the Microsoft official extensions.

Please, let me know if you test it on any of these logging libraries and the results.

Thank you.

from microsoft.extensions.logging.log4net.aspnetcore.

heapifyman avatar heapifyman commented on July 4, 2024

I found this issue, almost one year old without any progress. So it seems to be a problem of log4net in combination with dotnet core 2.

I tried with NLog and callsite-linenumber and callsite work as expected. Class-/methodname and line number show up in the log entries.

Serilog does not seem to support linenumbers out of the box - but apparently it's possible to implement it yourself. Haven't tried it, though.

I think I'm gonna switch to NLog. It seems to be working fine, so far.

from microsoft.extensions.logging.log4net.aspnetcore.

huorswords avatar huorswords commented on July 4, 2024

Thank you very much by the info. I'm sorry that I can't help you further on this.

from microsoft.extensions.logging.log4net.aspnetcore.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.