I made the change, but it still doesn't work. It still writes to only MainLog. Could you please send your sample application.
I wish the problem was with VB .NET. I like C# much more than I do VB .NET. Thanks, Ronnie. --- Chad Myers <[EMAIL PROTECTED]> wrote: > Ah-hah! I spent way too much time on this, > unfortunately, but the answer > is quite simple: You're using VB.NET. heh, sorry, I > had to! No, > seriously, the answer is really that your > <appender-ref> tag is > malformed. > > You have: > <appender-ref name="OtherFeedLog"/> > > Should be: > <appender-ref ref="OtherFeedLog"/> > > That fixed it for me in my sample test with your > code. > > -Chad > > -----Original Message----- > From: Ronnie Hayden [mailto:[EMAIL PROTECTED] > Sent: Sunday, May 30, 2004 11:43 PM > To: Log4NET User > Subject: RE: Independent FileAppenders > > I tried this. I am able to log to MainLog but not to > OtherLog. But when I add the OtherLogAppender to > root, > I am able to log to both logs (unfortunately not > independently). I placed a breakpoint in the > Application_Start method, where I call > DOMConfigurator.Configure(), and it always hits it. > So > that's also not a problem. > > I have included my code below. If anyone could > please > let me know what I am doing wrong, I would be very > grateful. Please feel free to let me know if you > have > any questions regarding the code. > > Thanks, > > Ronnie. > > The log4net section of my web.config is as follows: > <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="OtherFeedLog" > type="log4net.Appender.FileAppender,log4net" > > <param name="File" > value="C:\\Logs\\OtherFeedLog.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 ref="MainLog" /> > </root> > <logger name="OtherLogger" additivity="false"> > <level value="DEBUG"/> > <appender-ref name="OtherFeedLog"/> > </logger> > </log4net> > > I declare the logs as follows (in VB .NET): > Private oMainLog As ILog = > LogManager.GetLogger("MainLog") > Private oOtherLog As ILog = > LogManager.GetLogger("OtherLogger") > > I log messages like this: > oMainLog.Info("Main Message") > oMainLog.Warn("Main Message") > oMainLog.Debug("Main Message") > oMainLog.Error("Main Message") > oMainLog.Fatal("Main Message") > > oOtherLog.Info("Other Message") > oOtherLog.Warn("Other Message") > oOtherLog.Debug("Other Message") > oOtherLog.Error("Other Message") > oOtherLog.Fatal("Other Message") > > I configure the logs by using the following code in > the Application_Start method in Global.asax.vb: > log4net.Config.DOMConfigurator.Configure() > > > --- Chad Myers <[EMAIL PROTECTED]> wrote: > > Oops, I mean "have two different loggers log to > two > > different > > independent log appenders". > > > > -Chad > > > > -----Original Message----- > > From: Chad Myers [mailto:[EMAIL PROTECTED] > > Sent: Saturday, May 29, 2004 9:11 AM > > To: Log4NET User > > Subject: RE: Independent FileAppenders > > > > What I was saying is that I have an app I'm > > developing right now that > > does exactly what you're trying to do, have two > > different loggers log to > > two different independent loggers (i.e. Logger1 > goes > > to foo.log and > > Logger2 goes to bar.log) and it works just fine. > > > > I do it with a similar config to what you just > > mentioned. > > > > Now, to answer your question... you can't get a > > handle to appenders > > (well, you can, but it's not intuitive and you > > shouldn't need to do it > > anyhow) like MainLog or OtherLog. All you need to > > care about is the > > loggers such as "DataLogger" and all the other > > loggers under root. > > > > With that config, these two statements should > work: > > > > ILog defaultLog = LogManager.GetLogger("Blah"); > > ILog dataLog = LogManager.GetLogger("DataLogger"); > > > > defaultLog.Error("Test"); > > dataLog.Error("Data Test"); > > > > After your app exits, you should notice that > > MainLog.txt has "Test" in > > it and OtherLog.txt has "Data Test" in it. > > > > -c > > > > -----Original Message----- > > From: Ronnie Hayden > [mailto:[EMAIL PROTECTED] > > Sent: Saturday, May 29, 2004 3:45 AM > > To: Log4NET User > > Subject: RE: Independent FileAppenders > > > > 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" /> > === message truncated === __________________________________ Do you Yahoo!? Friends. Fun. Try the all-new Yahoo! Messenger. http://messenger.yahoo.com/
