You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4net-user@logging.apache.org by Ramaa Davanagere <RD...@mobius.com> on 2005/09/19 14:56:01 UTC

Including datetime stamp in the log messages.

 

I'm using a fileappender and logging messages to a text file.

 

My Fileappender and PatternLayout are set like this...

 

log4net.Appender.FileAppender oFileAppender = new
log4net.Appender.FileAppender();

log4net.Layout.PatternLayout oPatternLayout = new
log4net.Layout.PatternLayout();

oPatternLayout.Header = "[Begin]\r\n";

oPatternLayout.Footer = "[End]\r\n\r\n";

oPatternLayout.ConversionPattern = "%d %-5p %c %m%n";

 

But I want the output to look like the sample shown below. I want to include
the datetime stamp for each message that is logged to the text file followed
by the message type constants (debug, error, fatal, info, etc) and then my
log message. 

 

2005-08-30 08:56:27,968[120048]INFO
MyCompanyName.MyProductName.ErrorHandler - Void
WriteToLog_Info(System.String) about to write a log message

2005-08-30 08:57:58,890[129088]ERROR
MyCompanyName.MyProductName.ErrorHandler - Void
WriteToLog_Err(System.String): Object variable not set

 

Can somebody look at my conversionPattern string and let me know what is
wrong?

 

Thanks.

 


Re: Including datetime stamp in the log messages.

Posted by Ron Grabowski <ro...@yahoo.com>.
%date %level %message

--- Ramaa Davanagere <RD...@mobius.com> wrote:

> But I want the output to look like the sample shown below. I want to
> include
> the datetime stamp for each message that is logged to the text file
> followed
> by the message type constants (debug, error, fatal, info, etc) and
> then my
> log message.