log4net in c# application

  • Thread starter Thread starter SK
  • Start date Start date
S

SK

Hi,
I am using log4net in my c# application.Want to know how
to customize the log output format. I know that it can
be done using LayoutSkeleton class,but dont know what
other parameters to be given in the log4net config file.
Please help
 
If you did a standard install of log4net, then you will find the following two files under the directory that you installed log4net:

../doc/manual/introduction.html - this gives the high level overveiw as well as some
detailed examples.
../doc/sdk/net/1.1/log4net-sdk-net-1.1.chm
- this is the API documentation. Under the Layout
class are all of the options for the Layout option
in the config file.

HTH
 
Hi,

I tried giving <layout type
= "log4net.Layout.LayoutSkeleton">
But i get the following error
Failed to find default constructor for type
[log4net.Layout.LayoutSkeleton]

Please help......



-----Original Message-----
If you did a standard install of log4net, then you will
find the following two files under the directory that you
installed log4net:
../doc/manual/introduction.html - this gives the high level overveiw as well as some
detailed examples.
../doc/sdk/net/1.1/log4net-sdk-net-1.1.chm
- this is
the API documentation. Under the Layout
class are
all of the options for the Layout option
 
SK,

You will probably get more and better help if you use the mail list for Log4Net
http://logging.apache.org/log4net/support.html

For everything you are probably needing to do, you would do in an XML file.
I have included one for your review. You will note that I used the PatternLayout
to change the look of the output.

As David W, mentioned look at the \doc\sdk\net\1.1\log4net-sdk-net-1.1.chm
documentation. Go to log4net.Layout > PatternLayout Class and scroll down
to see what %p means. Just figure out what you want your output to look like
and then replace the string ConversionPattern string value below.

Cheers,
Dave


<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<log4net>
<!-- *********************************************************** -->
<!-- *********************************************************** -->
<appender name="MyConsoleAppender" type="log4net.Appender.ConsoleAppender">
<layout type="log4net.Layout.PatternLayout">
<param name="ConversionPattern" value="%d{yyyy'/'MM'/'dd HH':'mm':'ss} [%t] %-5p %c [%x] - %m%n" />
</layout>
</appender>
<!-- *********************************************************** -->
<!-- *********************************************************** -->
<logger name="SimpleTest.Class1" additivity="false">
<appender-ref ref="MyConsoleAppender" />
<level value="DEBUG" />
</logger>
<!-- *********************************************************** -->
<!-- *********************************************************** -->
<root>
<level value="ALL" />
<appender-ref ref="MyConsoleAppender" />
</root>
<!-- *********************************************************** -->
<!-- *********************************************************** -->
</log4net>
</configuration>

Hi,

I tried giving <layout type
= "log4net.Layout.LayoutSkeleton">
But i get the following error
Failed to find default constructor for type
[log4net.Layout.LayoutSkeleton]

Please help......



-----Original Message-----
If you did a standard install of log4net, then you will
find the following two files under the directory that you
installed log4net:
../doc/manual/introduction.html - this gives the high level overveiw as well as some
detailed examples.
../doc/sdk/net/1.1/log4net-sdk-net-1.1.chm
- this is
the API documentation. Under the Layout
class are
all of the options for the Layout option
in the config file.

HTH
--
David Williams, VB.NET MVP



.
 
Back
Top