logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Thielen" <da...@windward.net>
Subject RE: Trying to write a J# log wrapper - mostly there
Date Tue, 27 Sep 2005 20:16:38 GMT
That did it - thank you.

David Thielen
303-499-2544
www.windwardreports.com


-----Original Message-----
From: Ron Grabowski [mailto:rongrabowski@yahoo.com] 
Sent: Wednesday, September 21, 2005 10:16 PM
To: Log4NET User
Subject: RE: Trying to write a J# log wrapper - mostly there

In org.apache.log4j.Logger, change this:

 ((log4net.Core.LogImpl)log).get_Logger().Log(
  type, log4net.Core.Level.Error, "again" + message, null);

to this:

 log.get_Logger().Log(
  declaringType, log4net.Core.Level.Error, message, null);

Where declaringType is:

 private final static System.Type declaringType = 
  Class.ToType(org.apache.log4j.Logger.class);

This is the new output:

 System.out.println: starting
 
  %a: ConsoleApplication1.exe
  %c: LogTest.Program
  %C: LogTest.Program
  %F: C:\LogTest-2003\Program.jsl
  %l: LogTest.Program.main(C:LogTest-2003\Program.jsl:15)
  %L: 15
  %m: using log4net
  %M: main
 
 System.out.println: between
 
  %a: ConsoleApplication1.exe
  %c: LogTest.Program
  %C: LogTest.Program
  %F: C:\LogTest-2003\Program.jsl
  %l: LogTest.Program.main(C:\LogTest-2003\Program.jsl:17)
  %L: 17
  %m: using log4j
  %M: main
 
 System.out.println: done

You were telling log4net the wrong place to look for location
information on the stack. That's why it was returning question marks.

--- David Thielen <david@windward.net> wrote:

> Yep - that's it.
> 
> What I want to have happen is for the output right after "between",
> where it
> is called from my Logger.jsl to be identical to the first output
> (except for
> the line number).
> 
> So that the logging gives the file/line that called my log.error()
> rather
> than the file/line in Logger.jsl.
> 
> Does that make sense?
> 
> Thanks - dave
> 
> 
> -----Original Message-----
> From: Ron Grabowski [mailto:rongrabowski@yahoo.com] 
> Sent: Friday, September 16, 2005 1:51 PM
> To: Log4NET User
> Subject: RE: Trying to write a J# log wrapper - mostly there
> 
> I'm not using VS2005 :(
> 
> I changed the project over to VS2003 and was able to generate this
> screen shot:
> 
>  http://www.ronosaurus.com/log4net/2005-09-16_jsharp_and_log4net.png
> 
> Does that exhibit the behavior your experiencing? Should there not be
> question marks for the last two messages?
> 
> --- David Thielen <david@windward.net> wrote:
> 
> > Hi;
> > 
> > I put the zip file up on http://www.windward.net/log4j4net.ZIP -
> > anyone is
> > welcome to look at it, I'm giving it to the apache logging group if
> > they
> > want it once I'm done.
> > 
> > Look for the bugbug comments. Also, there is a project
> > WindwardReports in
> > the solution, but I did not include it as it's not needed. So just
> > delete
> > that project.
> > 
> > Thanks - dave
> > 
> > 
> > -----Original Message-----
> > From: Ron Grabowski [mailto:rongrabowski@yahoo.com] 
> > Sent: Friday, September 16, 2005 12:49 PM
> > To: Log4NET User
> > Subject: Re: Trying to write a J# log wrapper - mostly there
> > 
> > Unless someone has a better idea, I think your best bet is to make
> a
> > very very simple J# console app that demonstrates your problem and
> > make
> > it available for download somewhere (or email me off list) so we
> can
> > play around with it. Perhaps zip containing a directory with the
> > necessary files and the .sln file? Don't forget to include the
> > necessary .jar files (log4j.jar ???)
> > 
> > --- David Thielen <david@windward.net> wrote:
> > 
> > > Hi;
> > > 
> > >  
> > > 
> > > I am writing a J# wrapper around log4net. I am doing this by
> > > implementing
> > > the public classes in log4j using it's package/names so my java
> > code
> > > is
> > > common source between java and J#.
> > > 
> > >  
> > > 
> > > I have it working except it uses the file name & line number from
> > my
> > > Logger.jsl instead of the app that calls my logger.
> > > 
> > >  
> > > 
> > > I can't inherit from LoggerWrapperImpl because that is a C#
> class.
> > > (Would be
> > > cool if you could do that.)
> > > 
> > >  
> > > 
> > > So I did the following:
> > > 
> > >  
> > > 
> > > public class Logger
> > > 
> > > {
> > > 
> > >       private log4net.ILog log;
> > > 
> > >       private Logger(Class appClass)
> > > 
> > >       {
> > > 
> > >             log =
> > > log4net.LogManager.GetLogger(Class.ToType(appClass));
> > > 
> > >       }
> > > 
> > >       public void error(Object message)
> > > 
> > >       {
> > > 
> > >             log.Error(message);
> > > 
> > >       }
> > > 
> > > }
> > > 
> > >  
> > > 
> > > Which works fine, but has the filename/line number problem. So I
> > then
> > > tried:
> > > 
> > >       public void error(Object message)
> > > 
> > >       {
> > > 
> > >             ((log4net.Core.LogImpl)log).get_Logger().Log(type,
> > > log4net.Core.Level.Error, "again" + message, null);
> > > 
> > >       }
> > > 
> > >  
> > > 
> > > Which gave the app domain as the filename and 0 as the line
> number.
> > > 
> > >  
> > > 
> > > So...
> > > 
> > >  
> > > 
> > > Any suggestions on what to try next?
> > > 
> > >  
> > > 
> > > Thanks - dave
> > > 
> > >  
> > > 
> > > 
> > 
> > 
> > 
> 
> 
> 
> 


Mime
View raw message