logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ganapatiraju, Shiva \(OCFS\)" <Shiva.Ganapatir...@ocfs.state.ny.us>
Subject RE: Including datetime stamp in the log messages.
Date Mon, 19 Sep 2005 15:24:28 GMT
how do i write to event log on

1) User 

2) Machine Name

3) Client  Machine Name.

thanks

Shiva Ganapatiraju

New York State

Office of Children & Family Services

Information Technology/SSOP Project

518.403.9056

AD0149@dfa.state.ny.us

http://ocfs.state.nyenet/admin/ofm/rsu

 

________________________________

From: Ramaa Davanagere [mailto:RDAVANAG@mobius.com] 
Sent: Monday, September 19, 2005 11:06 AM
To: 'Log4NET User'
Subject: RE: Including datetime stamp in the log messages.




Thank you! Thank you! Thank you! Thank you! 

It works. But can you tell me why it needs to be done this way? Just
curious 


--------------------------------------------------------
This communication, together with any attachments hereto or links contained herein, is for
the sole use of the intended recipient(s) and may contain information that is confidential,
privileged, or legally protected, and as such is not a public document.  If you are not the
intended recipient, you are hereby notified that any review, disclosure, copying, dissemination,
distribution or use of this communication is STRICTLY PROHIBITED. If you have received this
communication in error, please notify the sender immediately by return e-mail message and
delete the original and all copies of the communication, along with any attachments hereto
or links herein, from your system. 

-----Original Message----- 

From: Nicko Cadell [mailto:nicko@neoworks.com] 
Sent: Monday, September 19, 2005 10:36 AM 
To: Log4NET User 
Subject: RE: Including datetime stamp in the log messages. 

Try 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 = "%date[%thread] %-5level 
%message%newline"; 
oPatternLayout.ActivateOptions(); 

oFileAppender.Layout = oPatternLayout; 

oFileAppender.File = .... 
oFileAppender.ActivateOptions(); 

Then configure log4net to use the oFileAppender. 


Cheers, 
Nicko 

> -----Original Message----- 
> From: Ramaa Davanagere [mailto:RDAVANAG@mobius.com] 
> Sent: 19 September 2005 14:26 
> To: 'Log4NET User' 
> Subject: RE: Including datetime stamp in the log messages. 
> 
> I'm using log4net 1.2.9.0 
> 
>  
> 
> Right now, my Fileappender output looks like this 
> 
>  
> 
> Void 
> WriteToLog_Info(System.String):busContent.clsSaveContent.Save( 
> ): After calling CreateContentCache() 
> 
> Void 
> WriteToLog_Info(System.String):busContent.clsSaveContent.Save( 
> ) - Leaving 
> 
> Void 
> WriteToLog_Info(System.String):busContent.clsRetrieveContent.R 
> etrieve() - Entering 
> 
>  
> 
> But I want it to look more like this... 
> 
>  
> 
> 2005-08-30 08:56:27,968[120048]INFO 
> busContent.clsSaveContent.Save(): After calling CreateContentCache() 
> 
> 2005-08-30 08:56:27,968[120049]INFO 
> busContent.clsSaveContent.Save(): Leaving 
> 
> 2005-08-30 08:56:27,968[120050]INFO 
> busContent.clsRetrieveContent.Retrieve() - Entering 
> 
> 2005-08-30 08:57:58,890[129088]ERROR 
> busContent.clsRetrieveContent.SetVersionNumber(): Object 
> variable not set 
> 
>  
> 
> 120049 should be the thread id. 
> 
>  
> 
> clsSaveContent and clsRetrieveContent are 2 classes of 
> busContent component. 
> 
>  
> 
> I'm more interested in getting the initial part (2005-08-30 
> 08:56:27,968[120048]INFO) of the message. 
> 
>  
> 
>  
> 
> -----Original Message----- 
> From: Nicko Cadell [mailto:nicko@neoworks.com] 
> Sent: Monday, September 19, 2005 9:04 AM 
> To: Log4NET User 
> Subject: RE: Including datetime stamp in the log messages. 
> 
>  
> 
> Which version of log4net are you using? 
> 
>  
> 
> What does the output of your FileAppender look like at the moment? 
> 
>  
> 
> In your desired output example you have a chunk in square 
> brackets (e.g. 
> 
> [120048]) between the date and the level name, what do you want here? 
> 
> Thread ID? 
> 
>  
> 
> From your example is "Void WriteToLog_Info(System.String)" 
> part of your 
> 
> log message text? 
> 
>  
> 
>  
> 
> Cheers, 
> 
> Nicko 
> 
>  
> 
> > -----Original Message----- 
> 
> > From: Ramaa Davanagere [mailto:RDAVANAG@mobius.com] 
> 
> > Sent: 19 September 2005 13:56 
> 
> > To: 'log4net-user@logging.apache.org' 
> 
> > Subject: 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. 
> 
> > 
> 
> >  
> 
> > 
> 
> > 
> 
>

Mime
View raw message