Chad,
I too was able to log to multiple files. The problem
arises when I need to log to two different files
seperately. That's why I believe it is not that
log4net is not able to access the file system.
But I think I know what is causing the problem. If my
log4net section in my web.config file looks like this:
<log4net debug="false">
<appender name="MainLog"
type="log4net.Appender.FileAppender,log4net" >
<param name="File" value="C:\\Logs\\MainLog.txt"
/>
<param name="AppendToFile" value="true" />
<layout
type="log4net.Layout.PatternLayout,log4net">
<param name="ConversionPattern" value="%d %-5p
%m%n" />
</layout>
</appender>
<appender name="OtherLog"
type="log4net.Appender.FileAppender,log4net" >
<param name="File"
value="C:\\Logs\\OtherLog.txt" />
<param name="AppendToFile" value="true" />
<layout
type="log4net.Layout.PatternLayout,log4net">
<param name="ConversionPattern" value="%d %-5p
%m%n" />
</layout>
</appender>
<root>
<level value="DEBUG"/>
<appender-ref name="MainLog"/>
</root>
<logger name="DataLogger" additivity="false">
<level value="DEBUG"/>
<appender-ref name="OtherLog"/>
</logger>
</log4net>
Assume I have a class called Logger, how do I get a
handle to MainLog and OtherLog. So I could invoke a
method (either Debug, Error, Fatal etc.) on each
object. For example in my Logger class I could type
oMainLog.Fatal("My Fatal Message") which would write
to C:\Logs\MainLog.txt, since oMainLog has a reference
to the MainLog Appender.
Thanks a lot.
Ronnie.
--- Chad Myers <[EMAIL PROTECTED]> wrote:
> I currently have an application (non-ASP.NET) that
> logs to multiple
> files and I use essentially the same type of config
> file that I posted
> to you as an example and you posted back.
>
> It works, I know it does because I use it every day.
>
> This is what makes me think that it has something to
> do with either a.)
> ASP.NET or b.) The way you're using it from ASP.NET
> or c.) Some type of
> permissions thing.
>
> Unfortunately I don't have time today to create a
> sample ASP.NET project
> to test this, but my guess is that other people are
> doing similar things
> so I'm confident that this is possible from ASP.NET.
>
> -Chad
>
> -----Original Message-----
> From: Ronnie Hayden [mailto:[EMAIL PROTECTED]
> Sent: Friday, May 28, 2004 12:10 AM
> To: Log4NET User
> Subject: RE: Independent FileAppenders
>
> Chad,
>
> Putting DOMConfigurator.Configure() in the
> Application_Start initialized log4net before I
> changed
> the log4net section in the web.config file. So, I
> doubt this is an issue.
>
> Could you please create (or send one that is already
> created) a Console Application that logs to two
> files
> seperately, and uses a Configuration file to
> configure
> log4net.
>
> Thanks,
>
> Ron.
>
>
> --- Chad Myers <[EMAIL PROTECTED]> wrote:
> > Your log4net config looks right, so other than
> that
> > it's an OS or
> > ASP.NET config issue or perhaps your code or
> > something.
> >
> > I'm not too familiar with logging from ASP.NET
> apps
> > as I haven't had to
> > do it yet, but perhaps putting the
> > DOMConfigurator.Configure() call in
> > the Application_Start might not be the best thing
> to
> > do. Perhaps it's
> > not initializing log4net properly in time?
> >
> > You might try looking at the [assembly:]
> attributes
> > for Log4net to
> > initialize when the assembly is loaded?
> >
> > -Chad
> >
> > -----Original Message-----
> > From: Ronnie Hayden
> [mailto:[EMAIL PROTECTED]
> > Sent: Thursday, May 27, 2004 9:11 PM
> > To: Log4NET User
> > Subject: RE: Independent FileAppenders
> >
> > Please help me out with this. It is important. Is
> > anyone able to do this? Or could it be that there
> is
> > a
> > bug in log4net? Or is this feature not yet
> > implemented?
> >
> > Please help.
> >
> > Ronnie.
> >
> > --- Ronnie Hayden <[EMAIL PROTECTED]> wrote:
> > > I tried it, but it still doesn't work, even if I
> > > give
> > > the User Group "Everyone", "Full Control"
> > > permission.
> > >
> > > Could some kind soul please make an ASP .NET
> > > application that does this and send me the
> > relevant
> > > files. Please.
> > >
> > > Thanks,
> > >
> > > Ronnie.
> > >
> > > --- Chad Myers <[EMAIL PROTECTED]> wrote:
> > > > That looks right.
> > > >
> > > > I missed that this is an ASP.NET app. Perhaps
> > the
> > > > ASPNET user (Win2K) or
> > > > the NETWORK user (Win2003) doesn't have access
> > to
> > > > write to C:\ (and very
> > > > well shouldn't!).
> > > >
> > > > You might try creating a folder called
> > c:\weblogs
> > > or
> > > > something and allow
> > > > ASPNET or NETWORK write access to it.
> > > >
> > > > -Chad
> > > >
> > > > -----Original Message-----
> > > > From: Ronnie Hayden
> > > [mailto:[EMAIL PROTECTED]
> > > > Sent: Wednesday, May 26, 2004 10:49 PM
> > > > To: Log4NET User
> > > > Subject: RE: Independent FileAppenders
> > > >
> > > > I tried this, but couldn't get it to work.
> > > >
> > > > My log4net section in the web.config file now
> > > looks
> > > > like this:
> > > >
> > > > <log4net debug="false">
> > > > <appender name="MainLog"
> > > > type="log4net.Appender.FileAppender,log4net" >
> > > > <param name="File"
> value="C:\\MainLog.txt"
> > > />
> > > > <param name="AppendToFile" value="true"
> />
> > > > <layout
> > > > type="log4net.Layout.PatternLayout,log4net">
> > > > <param name="ConversionPattern"
> > value="%d
> > > > %-5p
> > > > %m%n" />
> > > > </layout>
> > > > </appender>
> > > > <appender name="OtherLog"
> > > > type="log4net.Appender.FileAppender,log4net" >
> > > > <param name="File"
> > value="C:\\OtherLog.txt"
> > > />
> > > > <param name="AppendToFile" value="true"
> />
> > > > <layout
> > > > type="log4net.Layout.PatternLayout,log4net">
> > > > <param name="ConversionPattern"
> > value="%d
> > > > %-5p
> > > > %m%n" />
> > > > </layout>
> > > > </appender>
> > > > <root>
> > > > <level value="DEBUG"/>
> > > > <appender-ref name="MainLog"/>
> > > > </root>
> > > > <logger name="DataLogger"
> additivity="false">
> > > > <level value="DEBUG"/>
> > > > <appender-ref name="OtherLog"/>
> > > > </logger>
> > > > </log4net>
> > > >
> > > > My code-behind code looks like this:
> > > >
> > > > Private Shared ReadOnly oMainLog As ILog =
> > > > LogManager.GetLogger(GetType(TestLog4Net))
> > > >
> > > > Private Shared ReadOnly oDataLog As ILog =
> > > > LogManager.GetLogger("DataLogger")
> > > >
> > > > To log a message I use code like this:
> > > >
> > > > oMainLog.Fatal(txtMessage.Text)
> > > > or
> > > > oDataLog.Fatal(txtMessage.Text)
> > > >
> > > > My global.asax.vb has this line in the
> > > > Application_Start event:
> > > >
> > > > log4net.Config.DOMConfigurator.Configure()
> > > >
> > > > When I tried this, it didn't write to either
> of
> > > the
>
=== message truncated ===
__________________________________
Do you Yahoo!?
Friends. Fun. Try the all-new Yahoo! Messenger.
http://messenger.yahoo.com/