Thanks very much for your reply and examples. RobR
From: Ronen Mashal [mailto:[email protected]] Sent: Sunday, October 05, 2014 12:29 AM To: Log4NET User Subject: Re: Two logs have the same appenders Hello Rob, If you want to write the same messages to two separate files you should do the following: 1) Define two file appenders in the configuration file, each writing to a different file. 2) Create a logger (or specify in the "root" logger) that it uses both file appenders, something like this: <logger name="a.b.c.classname"> <appender-ref ref="filelogger1"/> <appender-ref ref="filelogger2"/> </logger> Now, if you want to direct different messages to different log files, you would have to define another logger and use that logger in the code. Here's an example: <logger name="a.b.c.classname"> <appender-ref ref="filelogger1"/> </logger> <logger name="a.b.c.classname.special"> <appender-ref ref="filelogger2"/> </logger> then in the code: ILog logger1 = log4net.LogManager.GetLogger(typeof(classname)); ILog logger2 = log4net.LogManager.GetLogger(typeof(classname).FullName + ".sepcial"); Now you'd be able to write different message to different files. There are other options that involve using filters if you want, for example, to write all messages to one log but only a subset to another. Ronen Mashal. On Fri, Oct 3, 2014 at 11:45 PM, Rob Richardson <[email protected]<mailto:[email protected]>> wrote: I want to get two independent sets of appender objects from the same configuration file, so that I can use different file names in a FileAppender, for example. But the standard way of getting appender objects is to use the LogManager object, which is static. Since there's only one LogManager, it will always return the same set of appender objects. So, I get one ILog object, get its FileAppender object, set its file name, and write a message, and it appears in the expected file. Then, I get another ILog object, get the FileAppender object, set its file name to some other file, and write a message, and that message appears in the second file. Finally, I go back to the first file appender, write another message, and it appears in the second appenders file. Is there a way to copy a FileAppender object, or to get a new object for the same appender name out of the LogManager? Thanks very much! RobR, who will probably have to just build the logger programmatically instead of using a configuration file -- <http://www.magicsoftware.com/>[Image removed by sender. email_sig]<http://www.magicsoftware.com/><http://www.magicsoftware.com/> Ronen Mashal Software Engineer | Magic Software Enterprises Ltd. Tel. +972-3-5389215 | Fax. +972-3-5389333 [email protected]<mailto:[email protected]> | www.magicsoftware.com<http://www.magicsoftware.com/?utm_source=email> | [Image removed by sender. Facebook] <http://www.facebook.com/MagicSoftwareEnterprises> [Image removed by sender. Twitter] <http://twitter.com/#%21/MagicSoftware> [Image removed by sender. Linkedin] <http://www.linkedin.com/e/gis/130018/09F34B270EFF> [Image removed by sender. YouTube] <http://www.youtube.com/MagicSoftware> [Image removed by sender. Google+] <https://plus.google.com/108972177316548101047/posts> [Image removed by sender. Magic Software Blog] <http://blog.magicsoftware.com/> DISCLAIMER. Information in this message and its attachments may be privileged or confidential. It is for the exclusive use of the intended recipient(s). If you are not one of the intended recipients, you are hereby informed that any use, disclosure, distribution, and/or copying of this information is strictly prohibited. If you receive this message in error, please notify the sender immediately and delete all copies of this message. We recommend that you scan your incoming Emails. We cannot accept responsibility for any transmitted viruses.
