Comments (6)
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:
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.
Thank you for the insights! I will try it with a debug build.
from microsoft.extensions.logging.log4net.aspnetcore.
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.
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.
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.
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)
- Missing Release Notes HOT 2
- Use it in a windows service console application HOT 1
- How to add SMTPAppender HOT 1
- Logging to different Log4Net loggers with dependency injection HOT 1
- Question about name HOT 3
- Thank you for the contribution.
- Does this work with .NET or .NET Core applications? HOT 1
- .net 7 HOT 2
- Need Example Logging Facade Use Outside of ASP HOT 2
- Enable internal debugging HOT 1
- Add .NET 8 support HOT 2
- Missing copyright notice in license
- Upgrading to net8.0 throws exception on startup. HOT 1
- Initialize without a config file HOT 1
- microsoft.extensions.logging.log4net.aspnetcore is missing NuGet package README file
- .NET8.0 XML Exception Problem HOT 4
- EventId Not Showing in Logs
- Logging latest scope value
- How do I configure log4net from in memory configuration xml element? HOT 1
- Any plan to upgrade log4net to 2.0.16 or later?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from microsoft.extensions.logging.log4net.aspnetcore.