[ 
https://issues.apache.org/jira/browse/LOG4NET-287?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13868272#comment-13868272
 ] 

Paul H. Harder II commented on LOG4NET-287:
-------------------------------------------

My, but that does sound complex.  While the idea of disallowing optimization 
may prove useful as a diagnostic, it won't work for production and I'm looking 
for a fix now.  Until a version of log4net comes out that fixes this issue, I 
will just duplicate some of what it does, by writing my own BuildLogString 
method:

myLogger.Info(Util.BuildLogString("Something happened here"));

That method uses StackFrame (GetFileLineNumber and GetFileName), 
PathGetFileNameWithoutExtension, Assembly.GetCallingAssembly().FullName, and a 
regex to build a string that contains what log4net should be putting out when 
it logs two levels of class, the line number, and a message.

my log4net config file section then uses conversion patterns like this:

<conversionPattern value="%utcdate{ISO8601} %-12thread %-5level 
%message%newline%exception"/>

This is not ideal, but it works, both in my console app test program and in the 
Windows service.

> Wrong line number for log 
> --------------------------
>
>                 Key: LOG4NET-287
>                 URL: https://issues.apache.org/jira/browse/LOG4NET-287
>             Project: Log4net
>          Issue Type: Bug
>          Components: Appenders
>    Affects Versions: 1.2.10
>         Environment: Windows XP, .NET 3.5, Microsot Virsual Studio
>            Reporter: Shuang yin Liu
>
> In our project, we use the line number function of log4net. Many of log line 
> numbers are 1 line after the actual line. Other are 2 or 3 lines gap(when 
> exception log is written or at the end of the main application).



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)

Reply via email to