log4net across the portal

log4net across the portal

Old forum URL: forums.lhotka.net/forums/t/5776.aspx


JohnB posted on Monday, November 10, 2008

I've wired in log4net to my application but just realized that I get no logging information when I am across the portal.

I am currently using Csla 3.0.4 and is there something special that I need to configure to have logging work across the portal?

MySampleApp:
In Startup: log4net.Config.XmlConfigurator.ConfigureAndWatch(New System.IO.FileInfo("src/logging/log4net.xml"))
Note: I have also tried "log4net.Config.XmlConfigurator.Configure()" where the log4net configuration is included in the app and web.config files.

MySampleLib:
In my subclass of a Csla object:

Protected Shared ReadOnly mLog As log4net.ILog = log4net.LogManager.GetLogger(GetType(T))

Again, any call to mLog works unless I am on the other side of the portal.

SomeMainForm:
Private Shared ReadOnly mLog As log4net.ILog = log4net.LogManager.GetLogger("MyMainForm")

Any call to mLog within this form works as expected.

Again, is there something special that I need to configure to have logging work across the portal? Any help would be greatly appreciated.

Thanks,
John

ajj3085 replied on Monday, November 10, 2008

You'll also have to configure it in the web.config of your remoting host as well.  Of course you shouldn't expect the logs on the server to ever appear on the client either.  It sounds like that's what you want, but I know of no easy way to get the logs back.  I'd actually argue that server logs should stay on the server as there could be a risk that you expose sensitive information about the server to the client.

JohnB replied on Monday, November 10, 2008

I don't quite follow you when you say "configure it in the web.config of your remoting host as well"

In my ApplicationEvents :MyApplication_Startup I have :
log4net.Config.XmlConfigurator.ConfigureAndWatch(New System.IO.FileInfo("src/logging/log4net.xml"))

Then each form and business object has:
Private Shared ReadOnly mLog As log4net.ILog = log4net.LogManager.GetLogger("MyMainForm")

I followed the configuration guidelines defined by log4net.

I am currently running everything on my local PC. I am not really concerned about whether the logs are on the client vs the server at this point. I would just be overjoyed to "see" anything logged across the portal.

John

ajj3085 replied on Tuesday, November 11, 2008

Ahh, I assumed you had a remote data portal setup.  If that's not the case, I don't know what to suggest.. I gave up on log4net a few years ago.

JohnB replied on Tuesday, November 11, 2008

No, sorry. I should have mentioned that part.

May I ask what did you use in it's place? Custom solution or another 3rd party?

Thanks,
John

ajj3085 replied on Tuesday, November 11, 2008

It depends on what you need to do.  I decided having detailed logging as an option wasn't really want I wanted... all I really was interested was a detailed exception report when an error occured, because users aren't very good at getting you that information.  My "logging" then just consists of sending me an unwound exception report, including stack trace, source, etc and the Message from the top level exception and down all the InnerExceptions.  I only log an event to the event log if the sending of the email fails.  Then I just use the .Net built in way to write to the event log.

If I were to want to log everything (or have it as an option), I'd probably look at log4net again... but just because I'm not aware of any competing framework.

triplea replied on Tuesday, November 11, 2008

I am using log4net and it appears to be logging everything fine, even when in the DataPortal_XYZ methods (and without the RunLocal attribute). Oh and this is using the local DataPortal setup.

Not sure what to suggest though since my setup is pretty much standard. Let me know if you need any more specific implementation information.

 

JohnB replied on Tuesday, November 11, 2008

I am not using the local portal. For testing purposes I am running everything on my local PC through the built in Cassini server for VS2008.

Thanks

triplea replied on Tuesday, November 11, 2008

Well then you have a remote dataportal set up, even if you are using Cassini on your local box? You should enable logging on the server as previously stated...

JohnB replied on Tuesday, November 11, 2008

That is correct and that is the original reason for my post. I cannot get logging while on the portal side. My guess is I have something mis-configured.

John

triplea replied on Tuesday, November 11, 2008

OK sorry I went in a circle there. Did you try the Web.config suggestion? You will need to set up the configuration twice, once on both end of the wire...

ajj3085 replied on Tuesday, November 11, 2008

Yes, you need to setup the web.config for the application which is starting cassini. 

There are a number of hurdles though configurating log4net while running under IIS; for one, the default IIS account doesn't have permission to create a new event log Source, because those are stored in the registry.  The best solution there is to create the source manually and then log4net will work fine.

However... I don't know what permissions Cassini runs under, and have never setup l4n to run under Cassnin... so I have no idea what issues you'll run into there.   I think you'll have to expand your search using google at this point.. I haven't heard anyone try this here yet.

Copyright (c) Marimer LLC