Thanks Nicko and Ron for your help.
I tried both suggestions but still no luck.
In web.config I have:
<configSections>
<section name="log4net"
type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"
requirePermission="false" />
</configSections>
as well as the log4net config section.
In Global.asax, in method "Application_Start" I have:
log4net.Config.XmlConfigurator.Configure();
The thing is, on my local machine it works (the test logs appear in the log
file), but when I add <trust level="Medium"/> to web.config to simulate the
host server, it doesn't work. No error message is generated either. I
uploaded the code to my web host too and find the same results.
What am I missing here?
Daniel
-----Original Message-----
From: Ron Grabowski [mailto:[EMAIL PROTECTED]
Sent: Sunday, July 09, 2006 8:51 PM
To: Log4NET User
Subject: Re: ASP .NET 2.0 Security error - Config problems - Any ideas?
See if this works:
log4Net and ASP.Net Medium Trust
http://tinyurl.com/njqh4
http://blogs.advantaje.com/blog/kevin/Net/2006/06/29/log4Net-and-ASP-Net-Med
ium-Trust.html
--- Daniel Miller <[EMAIL PROTECTED]> wrote:
> Hi there
>
>
>
> I'm using log4net with an ASP .NET 2.0 application. On my local
> machine all
> works well, but when deployed to an ISP, there are no logs.
>
>
>
> After much debugging, I discovered that log4net was failing on a
> "Security
> Error" (see error message below) - i.e., the server's trust level is
> Medium
> and blocks log4net from reading the config data. (When I used a
> separate
> log4net.config file this error was swallowed; it only showed up when
> I moved
> the config data to web.config).
>
>
>
> After much searching online, still no hope in sight (the trust level
> cannot
> be overridden for this server) and some claim there is no solution.
>
> (See
>
http://www.tisgoud.nl/blog/CommentView,guid,79cd746e-556a-4417-a1fe-fb429bd3
> 7f80.aspx)
>
>
>
> Any ideas? Suggestions?
>
>
>
> I've tried loading configuration data from Global.asax (using
> XmlConfigurator.Configure(),XmlConfigurator. ConfigureAndWatch(.),
> and the
> same for DOMConfigurator) and also using AssemblyInfo.cs ([assembly:
> log4net.Config.XmlConfigurator(ConfigFile="log4net.config",Watch=true
> )]),
> you name it.
>
>
>
> Thanks in advance.
>
>
>
> Daniel
>
>
>
> ---
>
> Error message:
>
>
>
> Security Exception
>
> Description: The application attempted to perform an operation not
> allowed
> by the security policy. To grant this application the required
> permission
> please contact your system administrator or change the application's
> trust
> level in the configuration file.
>
>
>
> Exception Details: System.Security.SecurityException: Request for the
> permission of type 'System.Configuration.ConfigurationPermission,
> System.Configuration, Version=2.0.0.0, Culture=neutral,
> PublicKeyToken=b03f5f7f11d50a3a' failed.
>
>
>
> Source Error:
>
>
>
> An unhandled exception was generated during the execution of the
> current web
> request. Information regarding the origin and location of the
> exception can
> be identified using the exception stack trace below.
>
>
>
> Stack Trace:
>
>
>
>
>
> [SecurityException: Request for the permission of type
> 'System.Configuration.ConfigurationPermission, System.Configuration,
> Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
> failed.]
>
> System.Security.CodeAccessSecurityEngine.Check(Object demand,
> StackCrawlMark& stackMark, Boolean isPermSet) +0
>
> System.Security.CodeAccessPermission.Demand() +59
>
>
>
System.Configuration.BaseConfigurationRecord.CheckPermissionAllowed(String
> configKey, Boolean requirePermission, Boolean isTrustedWithoutAptca)
> +65
>
>
>
>
>
>
>
>
>
>
----------------------------------------------------------------------------
> ----
>
> Version Information: Microsoft .NET Framework Version:2.0.50727.42;
> ASP.NET
> Version:2.0.50727.42
>
>