Hi,
 
Don't you also need to specify the assembly name where your class is in the 
type attribute of the layout element?  So if the class 
MyProject.Log.MyXMLLayout is in the assembly MyProject.Log you'd have
 
<layout type="MyProject.Log.MyXMLLayout, MyProject.Log" />
 
Thanks
Ian



Ian Dykes
Software Developer
Esendex Ltd

T: +44 (0)115 852 5762
F: +44 (0)115 852 5757
Email: mailto:[EMAIL PROTECTED]
Web: http://www.esendex.com/
Blog: http://devproj20.blogspot.com

Esendex: Every Message Matters


 
Confidentiality: This e-mail (and any associated files) is intended only for 
the use of [email protected] and may contain information that is 
confidential, subject to copyright or constitutes a trade secret. If you are 
not [email protected] you are hereby notified that any 
disclosure, copying or distribution of this message, or files associated with 
this message, is strictly prohibited. If you have received this message in 
error, please notify us immediately by replying to the message and then delete 
it from your computer. Messages sent to and from us may be monitored. The views 
expressed in this message are those of the author Ian Dykes and do not 
necessarily represent the views of Esendex Ltd.
 
Security: This e-mail and any attachments are believed to be free from any 
virus but it is the responsibility of the recipient to ensure this is so. 
E-mail is not a 100% secure communications medium. We recommend you observe 
this when e-mailing us.
 
Esendex Ltd is a limited company registered in the UK, with company number 
04217280 and having its registered office at 32a Stoney Street • Nottingham • 
NG1 1LL • United Kingdom.
 
[v1.1 EN]
________________________________



From: Lee, Matthew [mailto:[EMAIL PROTECTED] 
Sent: 27 February 2008 17:05
To: Log4NET User
Subject: RE: Proprieraty Layout Problem



Hi,

I think you might need to call the base element to actually perform the write 
of the event.  Maybe something like this:

namespace MyProject.Log
{
        public class MyXMLLayout : log4net.Layout.XmlLayout
        {
                public override void Format(System.IO.TextWriter writer, 
LoggingEvent loggingEvent)
                {

                //test layout
                writer.Write("NEW LOG ENTRY");
                base.Format(writer, loggingEvent);
                }
        }
}


Thanks,

Matt

________________________________

From: Cícero Raupp Rolim [mailto:[EMAIL PROTECTED]
Sent: Wednesday, February 27, 2008 10:50 AM
To: Log4NET User
Subject: Proprieraty Layout Problem


Hi!

I have one question again :D!

In my project (for Compact .NET Framework), we need implement a specified 
layout to logger. First, we included the log4net library in project and we 
extended the Xml like below:

using System;
using System.Collections.Generic;
using System.Text;
using log4net;
using log4net.Util;
using log4net.Core;

namespace MyProject.Log
{
    public class MyXMLLayout : log4net.Layout.XmlLayout
    {
        public override void Format(System.IO.TextWriter writer, LoggingEvent 
loggingEvent)
        {
            //test layout
            writer.Write("NEW LOG ENTRY");
        }
    }
}

I compiled the project and add layout attribute in log4net config file, like 
this:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <log4net>
    <appender name="RollingFileAppender" 
type="log4net.Appender.RollingFileAppender">
      <bufferSize value="0" />
      <file value="mylog.txt" />
      <appendToFile value="true" />
      <maxSizeRollBackups value="5" />
      <maximumFileSize value="100KB" />
      <rollingStyle value="Size" />
      <staticLogFileName value="true" />
      <layout type="MyProject.Log.MyXMLLayout" />
    </appender>
    <root>
      <level value="ALL" />
      <appender-ref ref="RollingFileAppender" />
    </root>
  </log4net>
</configuration>


When I run my project, the mylog.txt not contains the logged events of system. 
If I restore the config file with layouts provided by log4net, the software 
works fine. We need something else to do work this proprietary layout?

Sorry for my bad english :(.

Thanks's

Cícero



This message and any files transmitted with it are confidential and are 
intended solely for the use of the individual or entity to whom they are 
addressed.  If you have received this email in error, please delete the email 
and any files transmitted with it entirely from your computer.



Reply via email to